diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-07-04 16:45:19 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-07-06 11:42:47 +0200 |
| commit | febe2b3f828c25c7a4169f074536f686ca874ea2 (patch) | |
| tree | f8a0b490e7fac8aad5aee36fadd41d9f702cc71c /app/lib | |
| parent | a9ffd79035fad6bf8d90ba37028288be261b8aaa (diff) | |
| download | mullvadvpn-febe2b3f828c25c7a4169f074536f686ca874ea2.tar.xz mullvadvpn-febe2b3f828c25c7a4169f074536f686ca874ea2.zip | |
Improve error output in RpcServer
Diffstat (limited to 'app/lib')
| -rw-r--r-- | app/lib/ipc-facade.js | 4 | ||||
| -rw-r--r-- | app/lib/jsonrpc-ws-ipc.js | 15 |
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); }); } |
