diff --git a/pass/Controllers/GitServerSettingTableViewController.swift b/pass/Controllers/GitServerSettingTableViewController.swift index a0dd223..3ccaf46 100644 --- a/pass/Controllers/GitServerSettingTableViewController.swift +++ b/pass/Controllers/GitServerSettingTableViewController.swift @@ -230,10 +230,14 @@ class GitServerSettingTableViewController: UITableViewController { // might keys updated via iTunes, or downloaded/pasted inside the app fileActionTitle.append(" (Import)") let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in - self.passwordStore.gitSSHKeyImportFromFileSharing() - SharedDefaults[.gitSSHKeySource] = "file" - SVProgressHUD.showSuccess(withStatus: "Imported") - SVProgressHUD.dismiss(withDelay: 1) + do { + try self.passwordStore.gitSSHKeyImportFromFileSharing() + SharedDefaults[.gitSSHKeySource] = "file" + SVProgressHUD.showSuccess(withStatus: "Imported") + SVProgressHUD.dismiss(withDelay: 1) + } catch { + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) + } } optionMenu.addAction(fileAction) } else { diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index 6d00104..27c5430 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -410,7 +410,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV SVProgressHUD.dismiss(withDelay: 0.6) } } catch { - print(error) DispatchQueue.main.async { // remove the wrong passphrase so that users could enter it next time self.passwordStore.pgpKeyPassphrase = nil diff --git a/pass/Controllers/QRScannerController.swift b/pass/Controllers/QRScannerController.swift index 11d7643..0b7d6fe 100644 --- a/pass/Controllers/QRScannerController.swift +++ b/pass/Controllers/QRScannerController.swift @@ -80,9 +80,7 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg } } catch { - print(error) scannerOutput.text = error.localizedDescription - return } } diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index 9920e01..12657b5 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -91,9 +91,9 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele SVProgressHUD.setDefaultMaskType(.black) SVProgressHUD.setDefaultStyle(.light) SVProgressHUD.show(withStatus: "Fetching PGP Key") - passwordStore.pgpKeyImportFromFileSharing() DispatchQueue.global(qos: .userInitiated).async { [unowned self] in do { + try self.passwordStore.pgpKeyImportFromFileSharing() try self.passwordStore.initPGPKeys() DispatchQueue.main.async { self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpKeyID diff --git a/passAutoFillExtension/CredentialProviderViewController.swift b/passAutoFillExtension/CredentialProviderViewController.swift index bde232d..5688f4d 100644 --- a/passAutoFillExtension/CredentialProviderViewController.swift +++ b/passAutoFillExtension/CredentialProviderViewController.swift @@ -163,7 +163,6 @@ class CredentialProviderViewController: ASCredentialProviderViewController, UITa self.extensionContext.completeRequest(withSelectedCredential: passwordCredential, completionHandler: nil) } } catch { - print(error) DispatchQueue.main.async { // remove the wrong passphrase so that users could enter it next time self.passwordStore.pgpKeyPassphrase = nil diff --git a/passExtension/ExtensionViewController.swift b/passExtension/ExtensionViewController.swift index 0820f9e..f0dd016 100644 --- a/passExtension/ExtensionViewController.swift +++ b/passExtension/ExtensionViewController.swift @@ -189,7 +189,6 @@ class ExtensionViewController: UIViewController, UITableViewDataSource, UITableV } } } catch { - print(error) DispatchQueue.main.async { // remove the wrong passphrase so that users could enter it next time self.passwordStore.pgpKeyPassphrase = nil diff --git a/passKit/Helpers/Utils.swift b/passKit/Helpers/Utils.swift index 715cf41..6d91da4 100644 --- a/passKit/Helpers/Utils.swift +++ b/passKit/Helpers/Utils.swift @@ -13,12 +13,7 @@ import KeychainAccess public class Utils { public static func getPasswordFromKeychain(name: String) -> String? { let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier) - do { - return try keychain.getString(name) - } catch { - print(error) - } - return nil + return (try? keychain.getString(name)) ?? nil } public static func addPasswordToKeychain(name: String, password: String?) { @@ -28,20 +23,12 @@ public class Utils { public static func removeKeychain(name: String) { let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier) - do { - try keychain.remove(name) - } catch { - print(error) - } + try? keychain.remove(name) } public static func removeAllKeychain() { let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier) - do { - try keychain.removeAll() - } catch { - print(error) - } + try? keychain.removeAll() } public static func copyToPasteboard(textToCopy: String?) { guard textToCopy != nil else { diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index e45b7cf..a64d078 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -528,10 +528,6 @@ public class PasswordStore { private func gitMv(from: String, to: String) throws { let fromURL = storeURL.appendingPathComponent(from) let toURL = storeURL.appendingPathComponent(to) - guard fm.fileExists(atPath: fromURL.path) else { - print("\(from) not exist") - return - } try fm.moveItem(at: fromURL, to: toURL) try gitAdd(path: to) try gitRm(path: from) @@ -872,20 +868,12 @@ public class PasswordStore { } } - public func gitSSHKeyImportFromFileSharing() { - do { - try fm.moveItem(atPath: Globals.iTunesFileSharingSSHPrivate, toPath: Globals.gitSSHPrivateKeyPath) - } catch { - print(error) - } + public func gitSSHKeyImportFromFileSharing() throws { + try fm.moveItem(atPath: Globals.iTunesFileSharingSSHPrivate, toPath: Globals.gitSSHPrivateKeyPath) } - public func pgpKeyImportFromFileSharing() { - do { - try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPublic, toPath: Globals.pgpPublicKeyPath) - try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPrivate, toPath: Globals.pgpPrivateKeyPath) - } catch { - print(error) - } + public func pgpKeyImportFromFileSharing() throws { + try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPublic, toPath: Globals.pgpPublicKeyPath) + try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPrivate, toPath: Globals.pgpPrivateKeyPath) } }