aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/connect/src')
-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) {