An advanced Ethereum/EVM mobile wallet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
alpha-wallet-ios/AlphaWallet/Extensions/Error.swift

43 lines
1.5 KiB

// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import APIKit
import JSONRPCKit
import Result
extension Error {
var prettyError: String {
switch self {
case let error as AnyError:
switch error.error {
case let error as APIKit.SessionTaskError:
switch error {
case .connectionError(let error):
return error.localizedDescription
case .requestError(let error):
return error.localizedDescription
case .responseError(let error):
guard let JSONError = error as? JSONRPCError else {
return error.localizedDescription
}
switch JSONError {
case .responseError(_, let message, _):
return message
default: return R.string.localizable.undefinedError()
}
}
default:
return error.errorDescription ?? error.description
}
case let error as LocalizedError:
return error.errorDescription ?? R.string.localizable.unknownError()
case let error as NSError:
return error.localizedDescription
default:
return R.string.localizable.undefinedError()
}
}
var code: Int { return (self as NSError).code }
var domain: String { return (self as NSError).domain }
}