From d4378728b0d2861b69b67cf44263826aaf8f0902 Mon Sep 17 00:00:00 2001 From: Quentin Barbe Date: Mon, 17 Dec 2012 11:12:42 +0100 Subject: [PATCH] Handdle HTTP error to avoid throwing exceptions --- lib/sendgrid.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sendgrid.js b/lib/sendgrid.js index 12c8b8567..6d25c42d8 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -75,6 +75,8 @@ SendGrid.prototype.send = function(email, callback) { var json = JSON.parse(content); cb(json.message == 'success', json.errors); }); + }).on('error', function(error){ + return callback(false, error); }); // If the email has files, it will be a multipart request.