refactor: nicer errors
This commit is contained in:
parent
580440f42d
commit
5724d69488
|
@ -8,6 +8,19 @@ export default (latus) => class BundlePacket extends PacketClass {
|
||||||
return 'buffer';
|
return 'buffer';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static encode(packets) {
|
||||||
|
try {
|
||||||
|
return this.builder.encode(this.pack(packets));
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const packetTypes = packets
|
||||||
|
.map((packet) => normalize(latus, packet))
|
||||||
|
.map(({constructor: {type}}) => type);
|
||||||
|
error.message = `${this.type}(${packetTypes.join(', ')}): ${error.message}`;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static pack(packets) {
|
static pack(packets) {
|
||||||
// Pack up all the packets.
|
// Pack up all the packets.
|
||||||
const packedPackets = new Array(packets.length);
|
const packedPackets = new Array(packets.length);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user