check sendMail return code

This commit is contained in:
AJ ONeal 2018-07-07 22:31:41 +00:00
parent d12cddb1aa
commit b5fd940429
1 changed files with 16 additions and 2 deletions

View File

@ -10,6 +10,13 @@ var requestAsync = util.promisify(require('@coolaj86/urequest'));
var readFileAsync = util.promisify(fs.readFile);
var mkdirpAsync = util.promisify(require('mkdirp'));
var PromiseA;
try {
PromiseA = require('bluebird');
} catch(e) {
PromiseA = global.Promise;
}
var _auths = module.exports._auths = {};
var Auths = {};
Auths._no_pin = {
@ -200,8 +207,15 @@ function sendMail(state, auth) {
console.error(err);
}
});
// anything in the 200 range
if (2 === Math.floor(resp.statusCode / 100)) {
console.log("[DEBUG] email was sent, or so they say");
console.log(resp.body);
} else {
console.error("[Error] email failed to send, or so they say:");
console.error(resp.headers);
console.error(resp.statusCode, resp.body);
return PromiseA.reject(new Error("Error sending email: " + resp.statusCode + " " + resp.body));
}
});
}