Return appropriate error message on import wallet

Fix https://github.com/TrustWallet/trust-wallet-ios/issues/31
pull/2/head
Michael Scoff 7 years ago
parent cdef17e200
commit 0060b083a6
  1. 2
      Trust/EtherClient/EtherKeystore.swift
  2. 6
      Trust/EtherClient/KeyStoreError.swift
  3. 3
      Trust/Extensions/Error.swift

@ -54,7 +54,7 @@ class EtherKeystore: Keystore {
let _ = setPassword(password, for: account)
return (.success(account))
} catch {
return (.failure(.failedToImport))
return (.failure(.failedToImport(error)))
}
}

@ -5,7 +5,7 @@ import Foundation
enum KeyStoreError: LocalizedError {
case failedToDeleteAccount
case failedToDecryptKey
case failedToImport
case failedToImport(Error)
case failedToSignTransaction
var errorDescription: String? {
@ -14,8 +14,8 @@ enum KeyStoreError: LocalizedError {
return "Failed to delete account"
case .failedToDecryptKey:
return "Could not decrypt key with given passphrase"
case .failedToImport:
return "Failed to import keystore"
case .failedToImport(let error):
return error.localizedDescription
case .failedToSignTransaction:
return "Failed to sign transaction"
}

@ -31,4 +31,7 @@ extension Error {
return "Undefined Error"
}
}
var code: Int { return (self as NSError).code }
var domain: String { return (self as NSError).domain }
}

Loading…
Cancel
Save