summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-02-28 18:45:40 +0100
committerAndrej Mihajlov <and@mullvad.net>2019-03-01 16:41:58 +0100
commit5fcd445ffccd4e5c962d5eae02f6a7adcc147b1c (patch)
treee63c8108a26d77f890516314d3415d7a17426486 /gui
parentc65c6a96cb7598ebade5567e0816e2fc676798fc (diff)
downloadmullvadvpn-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')
-rw-r--r--gui/src/main/daemon-rpc.ts7
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);
}