Subj : spidermonkey "advanced" error reporting To : netscape.public.mozilla.jseng From : Jens Thiele Date : Sun Apr 25 2004 02:52 pm I am currently using JS_ReportError to report errors in native code and have registered my error handling function but JS_ReportError does not throw an Javscript exception like spidermonkey itself does. Example which should demonstrate my problem: bar is not defined print is my native function which calls JS_ReportError when it gets more than one argument (otherwise it does what is expected from a print function) function foo() { bar(); } try{ eval("foo();"); }catch(error){ println(error); println(error.stack); } try{ eval("print(1,2,2);"); }catch(error){ println(error); println(error.stack); } my output looks like this ReferenceError: bar is not defined foo()@/tmp/test.js:3 @/tmp/test.js:6 @/tmp/test.js:6 JSERROR: /tmp/test.js:12: Wrong number of arguments: expect 1, got 3 Flags: (Error number: 0) => the first error throws an exception and with the exception it is possible to get enough info to find the error the second error does not throw an exception and it is nearly impossible to find the error if it is nested somewhere in an eval or in a native function which calls back javascript again ( JS->C->JS->C->JS_ReportError...) so my question is how to throw an exception or how to get a stack trace otherwise is JS_SetPendingException(JSContext *cx, jsval v); the way to go? but then it seems impossible to inititalize the exception object with the public api? greetings karme .