summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-10-27 13:52:22 +0100
committerAndrej Mihajlov <and@mullvad.net>2020-10-27 13:52:22 +0100
commitbd82fd752c42fb7237747e116d2d3cc29388e7ba (patch)
tree6029530063455b4296212bd401fa436b2959059a
parent64f7b8fba73981dc4a52daf79924f50b2f1089d9 (diff)
parente012fe2460c49a19033924594a4e81c690dfc406 (diff)
downloadmullvadvpn-bd82fd752c42fb7237747e116d2d3cc29388e7ba.tar.xz
mullvadvpn-bd82fd752c42fb7237747e116d2d3cc29388e7ba.zip
Merge branch 'show-correct-error-on-login'
-rw-r--r--ios/CHANGELOG.md5
-rw-r--r--ios/MullvadVPN/DisplayChainedError.swift5
-rw-r--r--ios/MullvadVPN/LoginViewController.swift26
-rw-r--r--ios/MullvadVPN/MullvadRest.swift6
4 files changed, 35 insertions, 7 deletions
diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md
index e8844c186d..d46fc8e2a0 100644
--- a/ios/CHANGELOG.md
+++ b/ios/CHANGELOG.md
@@ -23,7 +23,9 @@ Line wrap the file at 100 chars. Th
## [Unreleased]
-
+### Fixed
+- Fix regression where "Internal error" was displayed instead of server error (i.e too many
+ WireGuard keys)
## [2020.4] - 2020-09-10
### Added
@@ -43,6 +45,7 @@ Line wrap the file at 100 chars. Th
- Remove the WireGuard key from the account inside the VPN tunnel during the log out, if VPN is
active at that time. Before it would always remove it outside the tunnel.
- Turn off WireGuard backend when there are no active network interfaces available. Saves battery.
+- Switch from JSON-RPC to REST communication protocol when talking to Mullvad API servers.
## [2020.3] - 2020-06-12
diff --git a/ios/MullvadVPN/DisplayChainedError.swift b/ios/MullvadVPN/DisplayChainedError.swift
index 8080d9d53b..8168323a31 100644
--- a/ios/MullvadVPN/DisplayChainedError.swift
+++ b/ios/MullvadVPN/DisplayChainedError.swift
@@ -16,7 +16,10 @@ extension RestError: DisplayChainedError {
var errorChainDescription: String? {
switch self {
case .network(let urlError):
- return urlError.localizedDescription
+ return String(
+ format: NSLocalizedString("Network error: %@", comment: ""),
+ urlError.localizedDescription
+ )
case .server(let serverError):
if let knownErrorDescription = serverError.errorDescription {
return knownErrorDescription
diff --git a/ios/MullvadVPN/LoginViewController.swift b/ios/MullvadVPN/LoginViewController.swift
index e92186f502..8c608fb39c 100644
--- a/ios/MullvadVPN/LoginViewController.swift
+++ b/ios/MullvadVPN/LoginViewController.swift
@@ -328,8 +328,30 @@ private extension LoginState {
switch error {
case .createAccount(let rpcError), .verifyAccount(let rpcError):
return rpcError.errorChainDescription ?? ""
- case .tunnelConfiguration:
- return NSLocalizedString("Internal error", comment: "")
+ case .tunnelConfiguration(let error):
+ if case .pushWireguardKey(let pushError) = error {
+ switch pushError {
+ case .network(let urlError):
+ return String(
+ format: NSLocalizedString("Network error: %@", comment: ""),
+ urlError.localizedDescription
+ )
+
+ case .server(let serverError):
+ var message = serverError.errorDescription ?? NSLocalizedString("Unknown server error.", comment: "")
+
+ if let recoverySuggestion = serverError.recoverySuggestion {
+ message.append("\n\(recoverySuggestion)")
+ }
+
+ return message
+
+ case .encodePayload, .decodeErrorResponse, .decodeSuccessResponse:
+ return NSLocalizedString("Internal error", comment: "")
+ }
+ } else {
+ return NSLocalizedString("Internal error", comment: "")
+ }
}
case .success(let method):
diff --git a/ios/MullvadVPN/MullvadRest.swift b/ios/MullvadVPN/MullvadRest.swift
index 09e2760c37..c28f282c08 100644
--- a/ios/MullvadVPN/MullvadRest.swift
+++ b/ios/MullvadVPN/MullvadRest.swift
@@ -51,9 +51,9 @@ struct ServerErrorResponse: LocalizedError, Decodable, RestResponse, Equatable {
var errorDescription: String? {
switch code {
case Code.keyLimitReached.rawValue:
- return NSLocalizedString("Too many public WireGuard keys", comment: "")
+ return NSLocalizedString("Too many WireGuard keys in use.", comment: "")
case Code.invalidAccount.rawValue:
- return NSLocalizedString("Invalid account", comment: "")
+ return NSLocalizedString("Invalid account.", comment: "")
default:
return nil
}
@@ -62,7 +62,7 @@ struct ServerErrorResponse: LocalizedError, Decodable, RestResponse, Equatable {
var recoverySuggestion: String? {
switch code {
case Code.keyLimitReached.rawValue:
- return NSLocalizedString("Remove unused WireGuard keys", comment: "")
+ return NSLocalizedString("Please visit the website to revoke a key before login is possible.", comment: "")
default:
return nil
}