From 5bcfdc853b2ff5a2390da3de30b006f85f5c837c Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 10 Jun 2017 20:42:29 +0000 Subject: Release of version 1.1.2. --- src/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/index.js b/src/index.js index 24bfd6e..0d1f801 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,10 @@ function connect(uuid, callback) { const request = http.request(query, function(response) { var json = ''; response.on('data', (raw) => json = decryptJSON(raw)); - response.on('end', () => callback(json.result)); + response.on('end', () => { + if (json.error) throw new Error(json.error.message); + callback(json.result); + }); }); request.on('error', (error) => Error(error.message)); @@ -59,7 +62,10 @@ function send(raw, callback) { const request = http.request(query, function(response) { var json = ''; response.on('data', (raw) => json = decryptJSON(raw)); - response.on('end', () => callback(json.result)); + response.on('end', () => { + if (json.error) throw new Error(json.error.message); + callback(json.result); + }); }); request.on('error', (error) => Error(error)); -- cgit v1.2.3