Subj : Re: [SpiderMonkey] Error Reporter Failure To : Brian Barnes From : Brendan Eich Date : Sat Jan 29 2005 11:34 pm Brian Barnes wrote: > I seem to be encountering a weird error. I have an error reporter > callback. Let's say I have two scripts, A and B, loaded into that > context. Scripts are executed on contexts, but not loaded into them -- are you thinking of global objects here? > Each has one function, funcA in A, and funcB in B. funcB has > a syntax error in it. That should be caught when the script containing funcB is compiled (or evaluated -- evaluate == compile + execute). Is it? If not, is it really a syntax error? > If my C code calls funcB, the error report gets called. > > If my C code calls funcA, which has a function that calls back into my C > code which in turn calls funcB, the code halts at the error line, fails > silently, and NEVER calls the error reporter. > > Case 1 --- Error Reporter gets Called ---- > > C code > funcB > halts at syntax error > Error Reporter > > Case 2 -- Error Reporter does not get Called ---- > > C code > funcA > C Code > funcB > halts at syntax error > > Has anybody seen this before? Any idea what might be causing this? Errors are now exceptions, since ECMA-262 Edition 3 support was added in '99 or so. That means your error reporter won't be called at the point where the error-as-exception is thrown. The engine reports uncaught exceptions only when unwinding from the outermost API calll. It can tell that an API is outermost by checking whether there are any activations (script executions or function invocations) live on the context you're passing in. So if your code does the right thing by propagating false or null failure returns to the outermost "C code" above, the uncaught error-as-exception that's thrown at the innermost funcB error point *will* be reported. If you are failing to propagate failure return values, fix that bug. If you're doing something else to "halt at syntax error", stop doing that (Dr., it hurts when I do this! ;-) and return false if an API fails, to propagate the exception. /be .