Skip to content
This repository was archived by the owner on May 18, 2020. It is now read-only.

Commit ef78e30

Browse files
committed
Error handling in restler
1 parent 743dc91 commit ef78e30

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sendinblue-api",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Official SendinBlue provided API V2 npm library",
55
"main": "sendinblue-api.js",
66
"scripts": {

sendinblue-api.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ SendinblueAPI.prototype.call = function(resource, method, input, cb) {
2626
cb('Request timed out within '+ms+' MS', null);
2727
})
2828
.on('complete', function(response) {
29-
var responseObj = JSON.parse(response);
30-
31-
cb(null, responseObj);
29+
if (response instanceof Error) {
30+
cb("Request Failed", null);
31+
} else {
32+
var responseObj = JSON.parse(response);
33+
cb(null, responseObj);
34+
}
3235
});
3336
};
3437

0 commit comments

Comments
 (0)