Skip to content

Commit

Permalink
error parsing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Badi committed Jun 16, 2016
1 parent e5aff46 commit f6ea667
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mailjet-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ MailjetClient.prototype.httpRequest = function (method, url, data, callback) {
*/
request[method](options, function (err, response, body) {
if (err || (response.statusCode > 210)) {
const error = new Error('Unsuccesfull')
error.ErrorMessage = body.ErrorMessage
error.statusCode = response.statusCode
if (typeof callback === 'function') {
callback(err || new Error(body), response)
callback(err || error, response)
}
const error = new Error(body)
error.statusCode = response.statusCode
reject(error)
reject(err || error)
} else {
if (typeof callback === 'function') {
callback(null, response, body)
Expand Down

0 comments on commit f6ea667

Please sign in to comment.