Skip to content

Commit

Permalink
Merge pull request #90 from sendgrid/pr/89
Browse files Browse the repository at this point in the history
From pr/89. Fixes error.data to error.message thanks to @timhaines
  • Loading branch information
motdotla committed Sep 18, 2013
2 parents 77c5637 + 0ffc6ad commit 9f8fe87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sendgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var Sendgrid = function(api_user, api_key, options) {

smtpTransport.sendMail(smtpParams, function(error, response) {
smtpTransport.close();
if(error) { return callback(new Error(error.data), null);}
if(error) { return callback(new Error(error.message), null);}

return callback(null, {'message': 'success'});
});
Expand Down
13 changes: 12 additions & 1 deletion test/integration/sendgrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,18 @@ describe('SendGrid #skip', function () {

it('has a blank send payload', function(done) {
sendgrid.send({}, function(err, json) {
expect(err.message).to.equal("501 Syntax error");
expect(err.message).to.equal("Mail from command failed - 501 Syntax error");

done();
});
});

it('has a blank TO', function(done) {
payload.subject += "has a blank TO";
payload.to = "";

sendgrid.send(payload, function(err, json) {
expect(err.message).to.equal("Can't send mail - no recipients defined");

done();
});
Expand Down

0 comments on commit 9f8fe87

Please sign in to comment.