Skip to content

Commit d7ce1e3

Browse files
committed
improve error handling
1 parent f29085b commit d7ce1e3

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

OpenDocumentReader/CoreWrapper.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath with:(NSStri
6363

6464
_pageNames = pageNames;
6565
_pagePaths = pagePaths;
66-
} catch (odr::UnknownFileType) {
66+
} catch (odr::UnknownFileType&) {
6767
_errorCode = @(-5);
6868
return false;
69-
} catch (odr::WrongPassword) {
69+
} catch (odr::WrongPassword&) {
7070
_errorCode = @(-2);
7171
return false;
7272
} catch (...) {

OpenDocumentReader/Document.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class Document: UIDocument {
125125
delegate?.documentLoadingCompleted(self)
126126
}
127127

128+
override func handleError(_ error: Error, userInteractionPermitted: Bool) {
129+
Crashlytics.crashlytics().record(error: error)
130+
}
131+
128132
override func writeContents(_ contents: Any, to url: URL, for saveOperation: UIDocument.SaveOperation, originalContentsURL: URL?) throws {
129133
var diff = ""
130134

OpenDocumentReader/DocumentViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ class DocumentViewController: UIViewController, DocumentDelegate, GADBannerViewD
233233
webview?.evaluateJavaScript("odr.searchNext(\"" + searchText + "\")", completionHandler: { (value: Any!, error: Error!) -> Void in
234234
if error != nil {
235235
Crashlytics.crashlytics().record(error: error)
236-
fatalError("search failed")
237236
}
238237
})
239238
}
@@ -242,7 +241,6 @@ class DocumentViewController: UIViewController, DocumentDelegate, GADBannerViewD
242241
webview?.evaluateJavaScript("odr.search(\"" + searchText + "\")", completionHandler: { (value: Any!, error: Error!) -> Void in
243242
if error != nil {
244243
Crashlytics.crashlytics().record(error: error)
245-
fatalError("search failed")
246244
}
247245
})
248246
}

0 commit comments

Comments
 (0)