From b9bebe3a119412955f1eeac26559db37d71483f0 Mon Sep 17 00:00:00 2001 From: Ian Scott Date: Wed, 18 May 2016 18:14:03 -0700 Subject: [PATCH] Unpack handshake error --- lib/handshake.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/handshake.js b/lib/handshake.js index 8f9c1c9..3297a3e 100644 --- a/lib/handshake.js +++ b/lib/handshake.js @@ -116,9 +116,14 @@ bl.unpack('C', function(res) { if (res[0] == 0) { // conection time error - // unpack error (? TODO) - var err = new Error; - cb(err); // TODO: detect that this is error on xcore side + // unpack error + bl.unpack('Cxxxxxx', function (rlen) { + bl.get(rlen[0], function (reason) { + var err = new Error; + err.message = 'X server connection failed: ' + reason.toString(); + cb(err); + }); + }); // TODO: do we need to close stream from our side? // TODO: api to close source stream via attached unpackstream return;