summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-07-15 13:26:02 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-07-22 18:35:43 +0300
commitfabf47dcb6fa12d2aed095422187cc0bc2b84e56 (patch)
tree8f5ff6211d32e42c2379bafb1d9b545d969cb371
parentc44e4c297769b3587929c6505e6ef5f7e1d58f95 (diff)
downloadmullvadvpn-fabf47dcb6fa12d2aed095422187cc0bc2b84e56.tar.xz
mullvadvpn-fabf47dcb6fa12d2aed095422187cc0bc2b84e56.zip
Adopt DisplayChainedError on RestError
-rw-r--r--ios/MullvadVPN/DisplayChainedError.swift28
1 files changed, 26 insertions, 2 deletions
diff --git a/ios/MullvadVPN/DisplayChainedError.swift b/ios/MullvadVPN/DisplayChainedError.swift
index ff6bd69528..cae6437af2 100644
--- a/ios/MullvadVPN/DisplayChainedError.swift
+++ b/ios/MullvadVPN/DisplayChainedError.swift
@@ -12,6 +12,30 @@ protocol DisplayChainedError {
var errorChainDescription: String? { get }
}
+extension RestError: DisplayChainedError {
+ var errorChainDescription: String? {
+ switch self {
+ case .network(let urlError):
+ return urlError.localizedDescription
+ case .server(let serverError):
+ if let knownErrorDescription = serverError.errorDescription {
+ return knownErrorDescription
+ } else {
+ return String(
+ format: NSLocalizedString("Server error: %@", comment: ""),
+ serverError.error ?? "(empty)"
+ )
+ }
+ case .encodePayload:
+ return NSLocalizedString("Server request encoding error", comment: "")
+ case .decodeSuccessResponse:
+ return NSLocalizedString("Server success response decoding error", comment: "")
+ case .decodeErrorResponse:
+ return NSLocalizedString("Server error response decoding error", comment: "")
+ }
+ }
+}
+
extension MullvadRpc.Error: DisplayChainedError {
var errorChainDescription: String? {
switch self {
@@ -114,8 +138,8 @@ extension Account.Error: DisplayChainedError {
var errorChainDescription: String? {
switch self {
- case .createAccount(let rpcError), .verifyAccount(let rpcError):
- return rpcError.errorChainDescription
+ case .createAccount(let restError), .verifyAccount(let restError):
+ return restError.errorChainDescription
case .tunnelConfiguration(let tunnelError):
return tunnelError.errorChainDescription