fix(WebSocketShard): add websocket send error handling (#2981)

* websocket send error handling

* fix: emit only when error is present

* refactor: use an if instead
This commit is contained in:
Will Nelson
2018-12-21 23:49:56 -08:00
committed by SpaceEEC
parent b5d5c699e6
commit 5cbdf38028
2 changed files with 4 additions and 1 deletions

View File

@@ -437,7 +437,9 @@ class WebSocketShard extends EventEmitter {
this.debug(`Tried to send packet ${data} but no WebSocket is available!`);
return;
}
this.ws.send(WebSocket.pack(data));
this.ws.send(WebSocket.pack(data), err => {
if (err) this.manager.client.emit(Events.ERROR, err);
});
}
/**

View File

@@ -13,6 +13,7 @@ client.on('ready', () => {
log('READY', client.user.tag, client.user.id);
});
client.on('rateLimit', log);
client.on('error', console.error);
const commands = {
eval: message => {