Skip to content

Instantly share code, notes, and snippets.

@purplefox
Created February 18, 2015 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purplefox/60619067006c3cc3eaee to your computer and use it in GitHub Desktop.
Save purplefox/60619067006c3cc3eaee to your computer and use it in GitHub Desktop.
var STDOUT = java.lang.System.out;
STDOUT.println("starting test");
var body =
"function() {\n" +
"// this is a common js module\n" +
"var num = 234;\n" +
"num.substr(1, 1);\n" +
"}\n// #sourceURL=wibble.js";
STDOUT.println("module source is:\n" + body);
var f = eval(body);
try {
f();
} catch (ex) {
if (ex instanceof TypeError) {
STDOUT.println("message is:" + ex.message);
STDOUT.println("line no is:" + ex.lineNumber);
STDOUT.println("filename is:" + ex.fileName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment