1
0
mirror of https://github.com/eleith/emailjs.git synced 2024-07-05 20:10:37 +00:00

Extend error message for bad command response

Include the error message sent by the server in the SMTPError message if available.
This commit is contained in:
Patrick Gansterer 2016-08-03 18:01:36 +02:00 committed by GitHub
parent b2c5f09d10
commit 956c85de0e

View File

@ -198,9 +198,15 @@ SMTP.prototype = {
if (err) {
caller(callback, err);
} else {
if (codes.indexOf(Number(msg.code)) != -1) caller(callback, err, msg.data, msg.message);
else caller(callback, SMTPError("bad response on command '" + cmd.split(' ')[0] + "'", SMTPError.BADRESPONSE, null, msg.data));
if (codes.indexOf(Number(msg.code)) != -1) {
caller(callback, err, msg.data, msg.message);
} else {
var errorMessage = "bad response on command '" + cmd.split(' ')[0] + "'";
if (msg.message) {
errorMessage += ': ' + msg.message;
}
caller(callback, SMTPError(errorMessage, SMTPError.BADRESPONSE, null, msg.data));
}
}
};