Mercurial > spidermonkey-playground
diff tcb.js @ 5:1f38f4f61768
added global lastException and lastExceptionTraceback properties to the TCB global, which are similar to python's exc_info().
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 19 Jun 2009 03:49:44 -0700 |
parents | 71de19be1054 |
children | 500e267ed094 |
line wrap: on
line diff
--- a/tcb.js Fri Jun 19 02:58:49 2009 -0700 +++ b/tcb.js Fri Jun 19 03:49:44 2009 -0700 @@ -1,6 +1,7 @@ -function printTraceback() { +function printTraceback(frame) { print("Traceback (most recent call last):"); - var frame = stack(); + if (frame === undefined) + frame = stack(); var lines = []; while (frame) { var line = (' File "' + frame.filename + '", line ' + @@ -15,7 +16,20 @@ print("Hello World."); } +function throwError() { + function innerThrowError() { + throw new Error("hi"); + } + innerThrowError(); +} + showInfo(); -printTraceback(); +try { + print("about to throw."); + throwError(); +} catch (e) { + printTraceback(lastExceptionTraceback); + print(e); +} var wrapped = wrap({}, {});