diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-11-03 19:56:48 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:58:44 +0100 |
| commit | 511c4eb17c91faf2176f3ff56dbf690589e5a0d0 (patch) | |
| tree | e632dba30536b65ac06a89f1dbb5a727acfcfe0c /gui/src/main | |
| parent | d5f21653bec09d342112d66c5d20eca38e16b49e (diff) | |
| download | mullvadvpn-511c4eb17c91faf2176f3ff56dbf690589e5a0d0.tar.xz mullvadvpn-511c4eb17c91faf2176f3ff56dbf690589e5a0d0.zip | |
Handle too many devices login error
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 13 | ||||
| -rw-r--r-- | gui/src/main/errors.ts | 6 |
2 files changed, 17 insertions, 2 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index f17505bd80..2ef9feb99d 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -54,7 +54,7 @@ import log from '../shared/logging'; import { ManagementServiceClient } from './management_interface/management_interface_grpc_pb'; import * as grpcTypes from './management_interface/management_interface_pb'; -import { CommunicationError, InvalidAccountError } from './errors'; +import { CommunicationError, InvalidAccountError, TooManyDevicesError } from './errors'; const NETWORK_CALL_TIMEOUT = 10000; const CHANNEL_STATE_TIMEOUT = 1000 * 60 * 60; @@ -259,7 +259,16 @@ export class DaemonRpc { } public async loginAccount(accountToken: AccountToken): Promise<void> { - await this.callString(this.client.loginAccount, accountToken); + try { + await this.callString(this.client.loginAccount, accountToken); + } catch (e) { + const error = e as grpc.ServiceError; + if (error.code == grpc.status.RESOURCE_EXHAUSTED) { + throw new TooManyDevicesError(); + } else { + throw error; + } + } } public async logoutAccount(): Promise<void> { diff --git a/gui/src/main/errors.ts b/gui/src/main/errors.ts index 261ee7a164..b7cc82c365 100644 --- a/gui/src/main/errors.ts +++ b/gui/src/main/errors.ts @@ -15,3 +15,9 @@ export class CommunicationError extends Error { super('api.mullvad.net is blocked, please check your firewall'); } } + +export class TooManyDevicesError extends Error { + constructor() { + super('Too many devices'); + } +} |
