Pass the original error around, and emit an error event on the client

This commit is contained in:
Robin Lambertz 2013-01-29 17:39:33 +00:00
parent d6b3a91751
commit fdc01db825
2 changed files with 6 additions and 2 deletions

View File

@ -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);

View File

@ -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;