summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-07-04 16:45:19 +0200
committerErik Larkö <erik@mullvad.net>2017-07-06 11:42:47 +0200
commitfebe2b3f828c25c7a4169f074536f686ca874ea2 (patch)
treef8a0b490e7fac8aad5aee36fadd41d9f702cc71c
parenta9ffd79035fad6bf8d90ba37028288be261b8aaa (diff)
downloadmullvadvpn-febe2b3f828c25c7a4169f074536f686ca874ea2.tar.xz
mullvadvpn-febe2b3f828c25c7a4169f074536f686ca874ea2.zip
Improve error output in RpcServer
-rw-r--r--app/lib/ipc-facade.js4
-rw-r--r--app/lib/jsonrpc-ws-ipc.js15
2 files changed, 15 insertions, 4 deletions
diff --git a/app/lib/ipc-facade.js b/app/lib/ipc-facade.js
index f82c0a326a..89c29ce795 100644
--- a/app/lib/ipc-facade.js
+++ b/app/lib/ipc-facade.js
@@ -43,7 +43,7 @@ export class RealIpc implements IpcFacade {
if (typeof raw === 'object' && raw && raw.paid_until) {
return raw;
} else {
- throw new InvalidReply(raw);
+ throw new InvalidReply(raw, 'Expected an object with paid_until');
}
});
}
@@ -78,7 +78,7 @@ export class RealIpc implements IpcFacade {
if (typeof raw === 'string' && raw) {
return raw;
} else {
- throw new InvalidReply(raw);
+ throw new InvalidReply(raw, 'Expected a string');
}
});
}
diff --git a/app/lib/jsonrpc-ws-ipc.js b/app/lib/jsonrpc-ws-ipc.js
index 7c8cf55302..44caf12d5c 100644
--- a/app/lib/jsonrpc-ws-ipc.js
+++ b/app/lib/jsonrpc-ws-ipc.js
@@ -40,9 +40,12 @@ export type JsonRpcSuccess = {
export type JsonRpcMessage = JsonRpcError | JsonRpcNotification | JsonRpcSuccess;
export class TimeOutError extends Error {
- constructor() {
+ jsonRpcMessage: Object;
+
+ constructor(jsonRpcMessage: Object) {
super('Request timed out');
this.name = 'TimeOutError';
+ this.jsonRpcMessage = jsonRpcMessage;
}
}
@@ -53,6 +56,11 @@ export class InvalidReply extends Error {
super(msg);
this.name = 'InvalidReply';
this.reply = reply;
+
+ if(msg) {
+ this.message = msg + ' - ';
+ }
+ this.message += JSON.stringify(reply);
}
}
@@ -93,8 +101,11 @@ export default class Ipc {
if (typeof subscriptionId === 'string' || typeof subscriptionId === 'number') {
this._subscriptions[subscriptionId] = listener;
} else {
- throw new InvalidReply(subscriptionId);
+ throw new InvalidReply(subscriptionId, 'The subscription id was not a string or a number');
}
+ })
+ .catch(e => {
+ log.error('Failed adding listener to', event, ':', e);
});
}