feat(v4.0.0-beta.5): BREAKING CHANGE: rename "error" event to "exception" to avoid unhandled exceptions

This commit is contained in:
tiagosiebler
2025-02-06 12:08:51 +00:00
parent a8f8d6bf15
commit 57b1a72b7f
10 changed files with 42 additions and 45 deletions

View File

@@ -91,7 +91,7 @@ function setWsClientEventListeners(
websocketClient.on('reconnected', (data) => {
console.log(new Date(), accountRef, 'ws has reconnected ', data?.wsKey);
});
websocketClient.on('error', (data) => {
websocketClient.on('exception', (data) => {
console.error(new Date(), accountRef, 'ws exception: ', data);
});
});

View File

@@ -117,7 +117,7 @@ function setWsClientEventListeners(
websocketClient.on('reconnected', (data) => {
console.log(new Date(), accountRef, 'ws has reconnected ', data?.wsKey);
});
websocketClient.on('error', (data) => {
websocketClient.on('exception', (data) => {
console.error(new Date(), accountRef, 'ws exception: ', data);
});
});

View File

@@ -40,8 +40,8 @@ wsClient.on('reconnected', (data) => {
wsClient.on('authenticated', (data) => {
console.log('ws has authenticated ', data?.wsKey);
});
wsClient.on('error', (data) => {
console.error('ws error: ', data);
wsClient.on('exception', (data) => {
console.error('ws exception: ', data);
});
async function main() {

View File

@@ -17,12 +17,8 @@ const logger = {
* - Heartbeats/ping/pong/reconnects are all handled automatically.
* If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you.
*/
const wsClient = new WebsocketClient(
{
// demoTrading: true,
},
logger,
);
const wsClient = new WebsocketClient();
wsClient.on('update', (data) => {
console.log('raw message received ', JSON.stringify(data));
@@ -40,9 +36,10 @@ wsClient.on('reconnect', ({ wsKey }) => {
wsClient.on('reconnected', (data) => {
console.log('ws has reconnected ', data?.wsKey);
});
// wsClient.on('error', (data) => {
// console.error('ws exception: ', data);
// });
wsClient.on('exception', (data) => {
console.error('ws exception: ', data);
});
/**
* For public V5 topics, use the subscribeV5 method and include the API category this topic is for.