chore: reporting

This commit is contained in:
cha0s 2021-03-14 09:10:10 -05:00
parent 4133c55dbc
commit dfbe25624e
2 changed files with 8 additions and 3 deletions

View File

@ -26,8 +26,7 @@ export default class Packet {
return this.builder.encode(this.pack(data)); return this.builder.encode(this.pack(data));
} }
catch (error) { catch (error) {
error.message = `${this.type}: ${error.message}`; throw new Error(`${this.type}: ${error.message}`);
throw error;
} }
} }

View File

@ -33,7 +33,13 @@ export default class Socket {
const packet = normalize(latus, packetOrDehydrated); const packet = normalize(latus, packetOrDehydrated);
const {constructor: Packet} = packet; const {constructor: Packet} = packet;
debug('sending packet %s(%j)', Packet.type, packet.data); debug('sending packet %s(%j)', Packet.type, packet.data);
return socket[method](Packet.id, deflate(Packet.encode(packet.data))); try {
const encoded = Packet.encode(packet.data);
return socket[method](Packet.id, deflate(encoded));
}
catch (error) {
throw new Error(`${error.message}, data: ${JSON.stringify(packet.data, null, 2)}`);
}
} }
send(packet) { send(packet) {