diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-05-15 13:16:57 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-05-17 19:35:08 +0200 |
| commit | a44c7247d40e9197f8021a467a9669f455e14bc7 (patch) | |
| tree | abbeb55e01e541d6232039efa1edef032bb6ed5d | |
| parent | cb7848ce01e03f35348bd337af282d2b37171b3b (diff) | |
| download | mullvadvpn-a44c7247d40e9197f8021a467a9669f455e14bc7.tar.xz mullvadvpn-a44c7247d40e9197f8021a467a9669f455e14bc7.zip | |
Unpack the JSON RPC errors
| -rw-r--r-- | ios/MullvadVPN/JsonRpc.swift | 16 |
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) } } |
