chore(): update examples for exception event
This commit is contained in:
@@ -377,8 +377,8 @@ ws.on('close', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Listen to raw error events. Recommended.
|
// Listen to raw error events. Recommended.
|
||||||
ws.on('error', (err) => {
|
ws.on('exception', (err) => {
|
||||||
console.error('error', err);
|
console.error('exception', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('reconnect', ({ wsKey }) => {
|
ws.on('reconnect', ({ wsKey }) => {
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ async function main() {
|
|||||||
const CANCEL_AFTER_SECONDS = 5;
|
const CANCEL_AFTER_SECONDS = 5;
|
||||||
|
|
||||||
// Exceptions including rejected commands will show here (as well as the catch handler used below)
|
// Exceptions including rejected commands will show here (as well as the catch handler used below)
|
||||||
wsClient.on('error', (data) => {
|
wsClient.on('exception', (data) => {
|
||||||
console.error('ws error: ', data);
|
console.error('ws exception: ', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Replies to commands will show here
|
// Replies to commands will show here
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ wsClient.on('reconnect', ({ wsKey }) => {
|
|||||||
wsClient.on('reconnected', (data) => {
|
wsClient.on('reconnected', (data) => {
|
||||||
console.log('ws has reconnected ', data?.wsKey);
|
console.log('ws has reconnected ', data?.wsKey);
|
||||||
});
|
});
|
||||||
// wsClient.on('error', (data) => {
|
// wsClient.on('exception', (data) => {
|
||||||
// console.error('ws exception: ', data);
|
// console.error('ws exception: ', data);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export type WsClientEvent =
|
|||||||
| 'open'
|
| 'open'
|
||||||
| 'update'
|
| 'update'
|
||||||
| 'close'
|
| 'close'
|
||||||
| 'error'
|
| 'exception'
|
||||||
| 'reconnect'
|
| 'reconnect'
|
||||||
| 'reconnected'
|
| 'reconnected'
|
||||||
| 'response';
|
| 'response';
|
||||||
@@ -46,7 +46,7 @@ export function waitForSocketEvent(
|
|||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
resolvedOnce = true;
|
resolvedOnce = true;
|
||||||
wsClient.removeListener(event, (e) => resolver(e));
|
wsClient.removeListener(event, (e) => resolver(e));
|
||||||
wsClient.removeListener('error', (e) => rejector(e));
|
wsClient.removeListener('exception', (e) => rejector(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolver(event) {
|
function resolver(event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user