improve error check

This commit is contained in:
Ivan Socolsky 2015-06-29 10:32:12 -03:00
parent 4552d3e524
commit c7691400c2
1 changed files with 3 additions and 1 deletions

View File

@ -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);
};