aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-31 10:10:33 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-03-31 10:10:33 -0700
commitad08fef3c97f16886b8bca6930b579c4610cd07a (patch)
treeb4506c65aaca3c3a34428459dc3b6a43db83df1e
parent30e9700d5a0693b043a2fb7c3010d0006905b5e5 (diff)
better error handling in EM_ASM
-rw-r--r--src/runtime.js8
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) {