diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-05-11 13:46:52 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-05-11 13:46:52 +0200 |
| commit | cb8712d758e120fde518f384fa3409683537adff (patch) | |
| tree | e554b1451b1a0c6001fa5eedf44dca291187d655 /gui/src/main | |
| parent | eb8c374b4dfff70a3b76b9ee36b248e8cb57e483 (diff) | |
| download | mullvadvpn-cb8712d758e120fde518f384fa3409683537adff.tar.xz mullvadvpn-cb8712d758e120fde518f384fa3409683537adff.zip | |
Handle error when failing to fetch devices
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 21 | ||||
| -rw-r--r-- | gui/src/main/errors.ts | 6 |
2 files changed, 21 insertions, 6 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 39e9d48f21..84e832cd5f 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -55,7 +55,12 @@ import { VoucherResponse, } from '../shared/daemon-rpc-types'; import log from '../shared/logging'; -import { CommunicationError, InvalidAccountError, TooManyDevicesError } from './errors'; +import { + CommunicationError, + InvalidAccountError, + ListDevicesError, + TooManyDevicesError, +} from './errors'; import { ManagementServiceClient } from './management_interface/management_interface_grpc_pb'; import * as grpcTypes from './management_interface/management_interface_pb'; @@ -527,12 +532,16 @@ export class DaemonRpc { } public async listDevices(accountToken: AccountToken): Promise<Array<IDevice>> { - const response = await this.callString<grpcTypes.DeviceList>( - this.client.listDevices, - accountToken, - ); + try { + const response = await this.callString<grpcTypes.DeviceList>( + this.client.listDevices, + accountToken, + ); - return response.getDevicesList().map(convertFromDevice); + return response.getDevicesList().map(convertFromDevice); + } catch { + throw new ListDevicesError(); + } } public async removeDevice(deviceRemoval: IDeviceRemoval): Promise<void> { diff --git a/gui/src/main/errors.ts b/gui/src/main/errors.ts index b7cc82c365..c3071f08a6 100644 --- a/gui/src/main/errors.ts +++ b/gui/src/main/errors.ts @@ -21,3 +21,9 @@ export class TooManyDevicesError extends Error { super('Too many devices'); } } + +export class ListDevicesError extends Error { + constructor() { + super('Failed to fetch list of devices'); + } +} |
