Skip to content

Commit c240f35

Browse files
committed
[template] +opts.noSilentError
1 parent 81a5f96 commit c240f35

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/template.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ function normalizePath(path) {
4646
return `${first}${normalized}`;
4747
}
4848

49-
module.exports = function parseTemplate(text = '', context = {}) {
49+
function logEvalError(text, context, value, err) {
50+
console.log(new Date, 'parseTemplate err', err);
51+
console.log('. text', text);
52+
console.log('. value', value);
53+
if (context['_@id']) {
54+
console.log('. _@id', context['_@id']);
55+
}
56+
}
57+
58+
module.exports = function parseTemplate(text = '', context = {}, opts = {}) {
5059
let result = '';
5160
const parsed = mustache.parse(text);
5261

@@ -62,8 +71,12 @@ module.exports = function parseTemplate(text = '', context = {}) {
6271
try {
6372
const evaluate = expressions.compile(value);
6473
value = evaluate(context);
65-
} catch (e) {
66-
console.log(new Date, 'parseTemplate err', e);
74+
} catch (err) {
75+
if (opts.noSilentError) {
76+
throw err;
77+
}
78+
logEvalError(text, context, value, err);
79+
6780
value = safe.get(context, value);
6881
}
6982
}

0 commit comments

Comments
 (0)