From c7691400c24171664810ef1a832a599530b8ac35 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Mon, 29 Jun 2015 10:32:12 -0300 Subject: [PATCH] improve error check --- lib/emailservice.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/emailservice.js b/lib/emailservice.js index f82c78c..7beab6e 100644 --- a/lib/emailservice.js +++ b/lib/emailservice.js @@ -140,14 +140,16 @@ EmailService.prototype._loadTemplate = function(emailType, recipient, extension, }; EmailService.prototype._applyTemplate = function(template, data, cb) { + var error; var result = _.mapValues(template, function(t) { try { return Mustache.render(t, data); } catch (e) { log.error('Could not apply data to template', e); - return cb(e); + error = e; } }); + if (error) return cb(error); return cb(null, result); };