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

Commit 6af5c61

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

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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)