Mercurial > people > rkennke > jdk9-shenandoah-final > nashorn
changeset 385:218c2833c344
8019365: Error stack format
Reviewed-by: hannesw
author | sundar |
---|---|
date | Fri, 28 Jun 2013 19:36:26 +0530 |
parents | f9c855b828fe |
children | 02588d68399d |
files | src/jdk/nashorn/api/scripting/NashornException.java src/jdk/nashorn/internal/objects/NativeError.java test/script/basic/JDK-8014781.js.EXPECTED test/script/basic/JDK-8017950.js.EXPECTED test/script/basic/JDK-8019226.js test/script/basic/JDK-8019226.js.EXPECTED |
diffstat | 6 files changed, 23 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk/nashorn/api/scripting/NashornException.java Thu Jun 27 13:24:50 2013 +0530 +++ b/src/jdk/nashorn/api/scripting/NashornException.java Fri Jun 28 19:36:26 2013 +0530 @@ -172,12 +172,13 @@ final StringBuilder buf = new StringBuilder(); final StackTraceElement[] frames = getScriptFrames((Throwable)exception); for (final StackTraceElement st : frames) { + buf.append("\tat "); buf.append(st.getMethodName()); - buf.append(" @ "); + buf.append(" ("); buf.append(st.getFileName()); buf.append(':'); buf.append(st.getLineNumber()); - buf.append('\n'); + buf.append(")\n"); } final int len = buf.length(); // remove trailing '\n'
--- a/src/jdk/nashorn/internal/objects/NativeError.java Thu Jun 27 13:24:50 2013 +0530 +++ b/src/jdk/nashorn/internal/objects/NativeError.java Fri Jun 28 19:36:26 2013 +0530 @@ -129,7 +129,7 @@ Global.checkObject(errorObj); final ScriptObject sobj = (ScriptObject)errorObj; final ECMAException exp = new ECMAException(sobj, null); - sobj.set("stack", NashornException.getScriptStackString(exp), false); + sobj.set("stack", getScriptStackString(sobj, exp), false); return UNDEFINED; } @@ -288,7 +288,7 @@ final Object exception = ECMAException.getException(sobj); if (exception instanceof Throwable) { - return NashornException.getScriptStackString((Throwable)exception); + return getScriptStackString(sobj, (Throwable)exception); } else { return ""; } @@ -362,4 +362,8 @@ throw new MethodHandleFactory.LookupException(e); } } + + private static String getScriptStackString(final ScriptObject sobj, final Throwable exp) { + return JSType.toString(sobj) + "\n" + NashornException.getScriptStackString(exp); + } }
--- a/test/script/basic/JDK-8014781.js.EXPECTED Thu Jun 27 13:24:50 2013 +0530 +++ b/test/script/basic/JDK-8014781.js.EXPECTED Fri Jun 28 19:36:26 2013 +0530 @@ -1,3 +1,4 @@ -MyError @ test/script/basic/JDK-8014781.js:32 -func @ test/script/basic/JDK-8014781.js:36 -<program> @ test/script/basic/JDK-8014781.js:39 +[object Object] + at MyError (test/script/basic/JDK-8014781.js:32) + at func (test/script/basic/JDK-8014781.js:36) + at <program> (test/script/basic/JDK-8014781.js:39)
--- a/test/script/basic/JDK-8017950.js.EXPECTED Thu Jun 27 13:24:50 2013 +0530 +++ b/test/script/basic/JDK-8017950.js.EXPECTED Fri Jun 28 19:36:26 2013 +0530 @@ -1,4 +1,5 @@ -func @ test/script/basic/JDK-8017950.js:33 -f @ test/script/basic/JDK-8017950.js:40 -g @ test/script/basic/JDK-8017950.js:44 -<program> @ test/script/basic/JDK-8017950.js:47 +Error + at func (test/script/basic/JDK-8017950.js:33) + at f (test/script/basic/JDK-8017950.js:40) + at g (test/script/basic/JDK-8017950.js:44) + at <program> (test/script/basic/JDK-8017950.js:47)
--- a/test/script/basic/JDK-8019226.js Thu Jun 27 13:24:50 2013 +0530 +++ b/test/script/basic/JDK-8019226.js Fri Jun 28 19:36:26 2013 +0530 @@ -30,7 +30,7 @@ function func1() { func2() } -function func2() { throw new Error() } +function func2() { throw new Error("failed!") } try { func1()
--- a/test/script/basic/JDK-8019226.js.EXPECTED Thu Jun 27 13:24:50 2013 +0530 +++ b/test/script/basic/JDK-8019226.js.EXPECTED Fri Jun 28 19:36:26 2013 +0530 @@ -1,3 +1,4 @@ -func2 @ test/script/basic/JDK-8019226.js:33 -func1 @ test/script/basic/JDK-8019226.js:31 -<program> @ test/script/basic/JDK-8019226.js:36 +Error: failed! + at func2 (test/script/basic/JDK-8019226.js:33) + at func1 (test/script/basic/JDK-8019226.js:31) + at <program> (test/script/basic/JDK-8019226.js:36)