From fdc01db82504cd81b7467988e37e6f22b544ed50 Mon Sep 17 00:00:00 2001 From: Robin Lambertz Date: Tue, 29 Jan 2013 17:39:33 +0000 Subject: [PATCH] Pass the original error around, and emit an error event on the client --- lib/client.js | 6 +++++- lib/protocol.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 26c3396..afa8ed0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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); diff --git a/lib/protocol.js b/lib/protocol.js index 58fd690..2c5598c 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -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;