diff --git a/lib/extensions/index.js b/lib/extensions/index.js index 5cf5e9b..46d3084 100644 --- a/lib/extensions/index.js +++ b/lib/extensions/index.js @@ -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); } }); - console.log("[DEBUG] email was sent, or so they say"); - console.log(resp.body); + // anything in the 200 range + if (2 === Math.floor(resp.statusCode / 100)) { + console.log("[DEBUG] email was sent, or so they say"); + } 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)); + } }); }