test/script/basic/errorstack.js

changeset 378
39e17373d8df
parent 7
5a1b0714df0e
child 952
6d5471a497fb
child 962
ac62e33a99b0
equal deleted inserted replaced
377:26a345c26e62 378:39e17373d8df
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 /** 24 /**
25 * "stack" property of Error objects. (nashorn extension). 25 * "getStackTrace()" method of Error objects. (nashorn extension).
26 * 26 *
27 * @test 27 * @test
28 * @run 28 * @run
29 */ 29 */
30 30
41 } 41 }
42 42
43 try { 43 try {
44 func1(); 44 func1();
45 } catch (e) { 45 } catch (e) {
46 // "stack" is java.lang.StackTraceElement object 46 var frames = e.getStackTrace();
47 for (i in e.stack) { 47 for (i in frames) {
48 print(e.stack[i].methodName + " : " + e.stack[i].lineNumber); 48 print(frames[i].methodName + " : " + frames[i].lineNumber);
49 } 49 }
50 } 50 }
51 51

mercurial