summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-05-28 00:42:05 +0200
committerErik Larkö <erik@mullvad.net>2017-05-28 17:15:08 +0200
commit7daa29b0b7d6fca52515bcbe9b43be5e6b63279d (patch)
tree21bd9b9bc28aa62f32024c321395700d78435c73 /app/lib
parenta99e3585e0f06657d0813ec65d8bab7423379d2d (diff)
downloadmullvadvpn-7daa29b0b7d6fca52515bcbe9b43be5e6b63279d.tar.xz
mullvadvpn-7daa29b0b7d6fca52515bcbe9b43be5e6b63279d.zip
JSONRPC communication tests
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/jsonrpc-ws-ipc.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/lib/jsonrpc-ws-ipc.js b/app/lib/jsonrpc-ws-ipc.js
index a327696e27..f2b54b38da 100644
--- a/app/lib/jsonrpc-ws-ipc.js
+++ b/app/lib/jsonrpc-ws-ipc.js
@@ -38,6 +38,13 @@ export type JsonRpcSuccess = {
}
export type JsonRpcMessage = JsonRpcError | JsonRpcNotification | JsonRpcSuccess;
+export class TimeOutError extends Error {
+ constructor() {
+ super('Request timed out');
+ this.name = 'TimeOutError';
+ }
+}
+
const DEFAULT_TIMEOUT_MILLIS = 750;
export default class Ipc {
@@ -119,7 +126,7 @@ export default class Ipc {
return;
}
- request.reject('The request timed out');
+ request.reject(new TimeOutError());
}
_onMessage(message: string) {
@@ -160,7 +167,7 @@ export default class Ipc {
clearTimeout(request.timeout);
if (message.type === 'error') {
- request.reject(message.payload.error.message);
+ request.reject(message.payload.error);
} else {
const reply = message.payload.result;
request.resolve(reply);