diff options
author | Valentin Popov <valentineus@gmail.com> | 2017-06-10 23:42:29 +0300 |
---|---|---|
committer | Valentin Popov <valentineus@gmail.com> | 2017-06-10 23:42:29 +0300 |
commit | 5bcfdc853b2ff5a2390da3de30b006f85f5c837c (patch) | |
tree | eefd2e2771eeb75fb9f8c9fd47ded11c03b67379 /src | |
parent | ea726a55b9b64bc0ef059ada8fa3daf56320b5a8 (diff) | |
download | iii-client-5bcfdc853b2ff5a2390da3de30b006f85f5c837c.tar.xz iii-client-5bcfdc853b2ff5a2390da3de30b006f85f5c837c.zip |
Release of version 1.1.2.
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 10 |
1 files changed, 8 insertions, 2 deletions
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)); |