Created
February 18, 2015 13:53
-
-
Save purplefox/f99ad4c78d246d2d6aee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var STDOUT = java.lang.System.out; | |
STDOUT.println("starting test"); | |
var body = | |
"function() {\n" + | |
"// deliberate syntax error\n" + | |
"v a r num = 234;\n" + | |
"}\n//@ sourceURL=wibble.js"; | |
STDOUT.println("module source is:\n" + body); | |
try { | |
eval(body); | |
} catch (ex) { | |
if (ex instanceof SyntaxError) { | |
STDOUT.println("message is:" + ex.message); | |
STDOUT.println("line no is:" + ex.lineNumber); | |
STDOUT.println("filename is:" + ex.fileName); | |
STDOUT.println("stack is:\n" + ex.stack); | |
var correctException = ex.nashornException.cause; | |
STDOUT.println("ne message is:" + correctException.message); | |
STDOUT.println("ne line no is:" + correctException.lineNumber); | |
STDOUT.println("ne filename is:" + correctException.fileName); | |
STDOUT.println("ne stack is:\n" + correctException.stack); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment