summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-05-15 13:16:57 +0200
committerAndrej Mihajlov <and@mullvad.net>2019-05-17 19:35:08 +0200
commita44c7247d40e9197f8021a467a9669f455e14bc7 (patch)
treeabbeb55e01e541d6232039efa1edef032bb6ed5d
parentcb7848ce01e03f35348bd337af282d2b37171b3b (diff)
downloadmullvadvpn-a44c7247d40e9197f8021a467a9669f455e14bc7.tar.xz
mullvadvpn-a44c7247d40e9197f8021a467a9669f455e14bc7.zip
Unpack the JSON RPC errors
-rw-r--r--ios/MullvadVPN/JsonRpc.swift16
1 files changed, 9 insertions, 7 deletions
diff --git a/ios/MullvadVPN/JsonRpc.swift b/ios/MullvadVPN/JsonRpc.swift
index a2e29fea19..ac1d44660c 100644
--- a/ios/MullvadVPN/JsonRpc.swift
+++ b/ios/MullvadVPN/JsonRpc.swift
@@ -29,20 +29,22 @@ extension JsonRpcRequest where T == NoData {
struct NoData: Encodable {}
class JsonRpcResponseError: Error, Decodable {
- let serverErrorMessage: String
+ let code: Int
+ let message: String
- init(serverErrorMessage: String) {
- self.serverErrorMessage = serverErrorMessage
+ var localizedDescription: String? {
+ return message
}
- var localizedDescription: String? {
- return serverErrorMessage
+ private enum CodingKeys: String, CodingKey {
+ case code, message
}
required init(from decoder: Decoder) throws {
- let container = try decoder.singleValueContainer()
+ let container = try decoder.container(keyedBy: CodingKeys.self)
- serverErrorMessage = try container.decode(String.self)
+ code = try container.decode(Int.self, forKey: .code)
+ message = try container.decode(String.self, forKey: .message)
}
}