aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-07-12 02:16:45 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-12 02:16:45 +0800
commit17c34716f99616066d3a4cec3256cdc4d0b96667 (patch)
tree65709baafbff96194a0d42f7ffa11ae4c2e33275 /packages/connect
parente12f7c3026dd513a6444092ea7654598c71548ae (diff)
downloaddexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.tar
dexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.tar.gz
dexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.tar.bz2
dexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.tar.lz
dexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.tar.xz
dexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.tar.zst
dexon-0x-contracts-17c34716f99616066d3a4cec3256cdc4d0b96667.zip
Provide subscriptionOpts in error callback and include url in error messages
Diffstat (limited to 'packages/connect')
-rw-r--r--packages/connect/src/types.ts2
-rw-r--r--packages/connect/src/ws_orderbook_channel.ts17
2 files changed, 13 insertions, 6 deletions
diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts
index 7347beb0b..fc7a4b24d 100644
--- a/packages/connect/src/types.ts
+++ b/packages/connect/src/types.ts
@@ -39,7 +39,7 @@ export interface OrderbookChannelHandler {
subscriptionOpts: OrderbookChannelSubscriptionOpts,
order: SignedOrder,
) => void;
- onError: (channel: OrderbookChannel, err: Error) => void;
+ onError: (channel: OrderbookChannel, err: Error, subscriptionOpts?: OrderbookChannelSubscriptionOpts) => void;
onClose: (channel: OrderbookChannel) => void;
}
diff --git a/packages/connect/src/ws_orderbook_channel.ts b/packages/connect/src/ws_orderbook_channel.ts
index e6a1322d2..e5d31607a 100644
--- a/packages/connect/src/ws_orderbook_channel.ts
+++ b/packages/connect/src/ws_orderbook_channel.ts
@@ -69,15 +69,18 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
}
private _handleWebSocketMessage(message: any): void {
if (_.isUndefined(message.data)) {
- this._handler.onError(this, new Error(`Message does not contain utf8Data`));
+ this._handler.onError(this, new Error(`Message does not contain data. Url: ${this._client.url}`));
return;
}
try {
- const utf8Data = message.data;
- const parserResult = orderbookChannelMessageParser.parse(utf8Data);
+ const data = message.data;
+ const parserResult = orderbookChannelMessageParser.parse(data);
const subscriptionOpts = this._subscriptionOptsList[parserResult.requestId];
if (_.isUndefined(subscriptionOpts)) {
- this._handler.onError(this, new Error(`Message has unknown requestId: ${utf8Data}`));
+ this._handler.onError(
+ this,
+ new Error(`Message has unknown requestId. Url: ${this._client.url} Message: ${data}`),
+ );
return;
}
switch (parserResult.type) {
@@ -90,7 +93,11 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
break;
}
default: {
- this._handler.onError(this, new Error(`Message has unknown type parameter: ${utf8Data}`));
+ this._handler.onError(
+ this,
+ new Error(`Message has unknown type parameter. Url: ${this._client.url} Message: ${data}`),
+ subscriptionOpts,
+ );
}
}
} catch (error) {