mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 22:23:21 -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) {
|
while (true) {
|
||||||
parsed = parsePacket(incomingBuffer, self.isServer);
|
parsed = parsePacket(incomingBuffer, self.isServer);
|
||||||
if (! parsed) break;
|
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;
|
packet = parsed.results;
|
||||||
incomingBuffer = incomingBuffer.slice(parsed.size);
|
incomingBuffer = incomingBuffer.slice(parsed.size);
|
||||||
self.emit(packet.id, packet);
|
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 is undef, error stays undef'd
|
||||||
if (readResults.error) {
|
if (readResults.error) {
|
||||||
return {
|
return {
|
||||||
error: new Error("reader failed : " + readResults.error)
|
error: readResults.error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results[fieldInfo.name] = readResults.value;
|
results[fieldInfo.name] = readResults.value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user