check sendMail return code
This commit is contained in:
		
							parent
							
								
									d12cddb1aa
								
							
						
					
					
						commit
						b5fd940429
					
				| @ -10,6 +10,13 @@ var requestAsync = util.promisify(require('@coolaj86/urequest')); | |||||||
| var readFileAsync = util.promisify(fs.readFile); | var readFileAsync = util.promisify(fs.readFile); | ||||||
| var mkdirpAsync = util.promisify(require('mkdirp')); | var mkdirpAsync = util.promisify(require('mkdirp')); | ||||||
| 
 | 
 | ||||||
|  | var PromiseA; | ||||||
|  | try { | ||||||
|  |   PromiseA = require('bluebird'); | ||||||
|  | } catch(e) { | ||||||
|  |   PromiseA = global.Promise; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| var _auths = module.exports._auths = {}; | var _auths = module.exports._auths = {}; | ||||||
| var Auths = {}; | var Auths = {}; | ||||||
| Auths._no_pin = { | Auths._no_pin = { | ||||||
| @ -200,8 +207,15 @@ function sendMail(state, auth) { | |||||||
|         console.error(err); |         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("[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)); | ||||||
|  |     } | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user