add error handling to share extension

This commit is contained in:
Maurice Parker 2019-09-12 11:24:43 -05:00
parent 5985b00480
commit 0225d5003f
2 changed files with 8 additions and 6 deletions

View File

@ -20,6 +20,8 @@ class ShareViewController: SLComposeServiceViewController {
override func viewDidLoad() { override func viewDidLoad() {
AccountManager.shared = AccountManager(accountsFolder: RSDataSubfolder(nil, "Accounts")!)
title = "NetNewsWire" title = "NetNewsWire"
placeholder = "Feed Name (Optional)" placeholder = "Feed Name (Optional)"
if let button = navigationController?.navigationBar.topItem?.rightBarButtonItem { if let button = navigationController?.navigationBar.topItem?.rightBarButtonItem {
@ -98,13 +100,13 @@ class ShareViewController: SLComposeServiceViewController {
account!.createFeed(url: url!.absoluteString, name: feedName, container: container) { result in account!.createFeed(url: url!.absoluteString, name: feedName, container: container) { result in
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
switch result { switch result {
case .success(let feed): case .success:
break self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
case .failure(let error): case .failure(let error):
print(error.localizedDescription) self.presentError(error) {
self.extensionContext!.cancelRequest(withError: error)
}
} }
} }

@ -1 +1 @@
Subproject commit 7af10d021f35df5596fa898ba55f5173fcb0e26b Subproject commit d640a2310b96a0a3d4d34c49c08c7bce195d0762