From af63b77c9b8a2cd3564fff58a9d324b8ef13b914 Mon Sep 17 00:00:00 2001 From: s2 Date: Sat, 8 Feb 2020 17:57:05 +0100 Subject: [PATCH] add more logs --- ejs-render-remote.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ejs-render-remote.js b/ejs-render-remote.js index d5efdea..6a4fe83 100644 --- a/ejs-render-remote.js +++ b/ejs-render-remote.js @@ -25,7 +25,12 @@ //if the template is already cached, return it and we are done if (templateFn) { - return templateFn(data); + try { + return templateFn(data); + } catch(ex) { + console.error(ex); + throw ex; + } } else { //if the template is not cached, we need to get it and render it later once we have it. remember: this happens only if the template is not already cached @@ -69,17 +74,16 @@ } else { $.get(templateUrl) .then(function(template) { - var templateOptions = overwriteWithCacheOptions(options, templateUrl); try { + var templateOptions = overwriteWithCacheOptions(options, templateUrl); var templateFn = ejs.compile(template, templateOptions); + ejs.cache.set(templateUrl, templateFn); + d.resolve(templateUrl); } catch(ex) { console.error(templateUrl, ex); d.reject(ex); throw ex; } - ejs.cache.set(templateUrl, templateFn); - - d.resolve(templateUrl); }); }