From ba3cb3b646caf877b73e4ad8391866f4dc19cd2b Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Fri, 4 Aug 2017 12:02:50 +0200 Subject: [PATCH] Do not crash the whole cloudron if an email template does not render but report the ejs error --- src/mailer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mailer.js b/src/mailer.js index cbf1674fd..ed98eaa8d 100644 --- a/src/mailer.js +++ b/src/mailer.js @@ -149,7 +149,15 @@ function render(templateFile, params) { assert.strictEqual(typeof templateFile, 'string'); assert.strictEqual(typeof params, 'object'); - return ejs.render(safe.fs.readFileSync(path.join(MAIL_TEMPLATES_DIR, templateFile), 'utf8'), params); + var content = null; + + try { + content = ejs.render(safe.fs.readFileSync(path.join(MAIL_TEMPLATES_DIR, templateFile), 'utf8'), params); + } catch (e) { + console.error(e); + } + + return content; } function getAdminEmails(callback) {