mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Pass the original error around, and emit an error event on the client
This commit is contained in:
parent
d6b3a91751
commit
fdc01db825
@ -29,7 +29,11 @@ Client.prototype.setSocket = function(socket) {
|
||||
while (true) {
|
||||
parsed = parsePacket(incomingBuffer, self.isServer);
|
||||
if (! parsed) break;
|
||||
if (parsed.error) this.end(parsed.error.message);
|
||||
if (parsed.error) {
|
||||
this.emit('error', parsed.error);
|
||||
this.end("ProtocolError");
|
||||
return;
|
||||
}
|
||||
packet = parsed.results;
|
||||
incomingBuffer = incomingBuffer.slice(parsed.size);
|
||||
self.emit(packet.id, packet);
|
||||
|
@ -1232,7 +1232,7 @@ function parsePacket(buffer, isServer) {
|
||||
// if readResults.error is undef, error stays undef'd
|
||||
if (readResults.error) {
|
||||
return {
|
||||
error: new Error("reader failed : " + readResults.error)
|
||||
error: readResults.error
|
||||
}
|
||||
}
|
||||
results[fieldInfo.name] = readResults.value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user