Skip to content

Commit

Permalink
parseTools: print problematic macro code on eval failure (#11749)
Browse files Browse the repository at this point in the history
This makes it much easier to develop Emscripten JS code that uses {{{ macros }}}.
  • Loading branch information
kainino0x authored Jul 29, 2020
1 parent 3d615be commit df56ba1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
function processMacros(text) {
return text.replace(/{{{([^}]|}(?!}))+}}}/g, function(str) {
str = str.substr(3, str.length-6);
var ret = eval(str);
try {
var ret = eval(str);
} catch (ex) {
ex.stack = 'In the following macro:\n\n' + str + '\n\n' + ex.stack;
throw ex;
}
return ret !== null ? ret.toString() : '';
});
}
Expand Down

0 comments on commit df56ba1

Please sign in to comment.