diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-02-28 18:45:40 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-03-01 16:41:58 +0100 |
| commit | 5fcd445ffccd4e5c962d5eae02f6a7adcc147b1c (patch) | |
| tree | e63c8108a26d77f890516314d3415d7a17426486 /gui/src/main | |
| parent | c65c6a96cb7598ebade5567e0816e2fc676798fc (diff) | |
| download | mullvadvpn-5fcd445ffccd4e5c962d5eae02f6a7adcc147b1c.tar.xz mullvadvpn-5fcd445ffccd4e5c962d5eae02f6a7adcc147b1c.zip | |
Properly handle the edge case when the daemon is not able to return the location
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 69ed725d52..a52c3b431a 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -387,7 +387,12 @@ export class DaemonRpc { public async getLocation(): Promise<ILocation | undefined> { const response = await this.transport.send('get_current_location', [], NETWORK_CALL_TIMEOUT); try { - return camelCaseObjectKeys(validate(locationSchema, response)) as ILocation; + const validatedObject = validate(locationSchema, response); + if (validatedObject) { + return camelCaseObjectKeys(validatedObject) as ILocation; + } else { + return undefined; + } } catch (error) { throw new ResponseParseError('Invalid response from get_current_location', error); } |
