diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-31 10:10:33 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-31 10:10:33 -0700 |
commit | ad08fef3c97f16886b8bca6930b579c4610cd07a (patch) | |
tree | b4506c65aaca3c3a34428459dc3b6a43db83df1e | |
parent | 30e9700d5a0693b043a2fb7c3010d0006905b5e5 (diff) |
better error handling in EM_ASM
-rw-r--r-- | src/runtime.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime.js b/src/runtime.js index edcbf637..63610d3b 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -409,7 +409,13 @@ var Runtime = { abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)'); } } - return Runtime.asmConstCache[code] = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node + try { + var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node + } catch(e) { + Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)'); + throw e; + } + return Runtime.asmConstCache[code] = evalled; }, warnOnce: function(text) { |