Re: what is the replacement of JS_SetErrorReporter in spidermonkey 60
Boris Zbarsky <[email protected]> Wed, 10 Apr 2019 16:06:35 -0400
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
On 4/10/19 3:36 PM, msami wrote:
> I want to report errors from js engine to c++ code side.
The idea in the new setup is that whatever code is doing the entrypoint
into the JS engine should deal with the resulting exception, if any,
instead of having some unrelated code called that should guess how to deal.
So your code should generally look like this, given a `JSContext* cx`:
if (!JS::Call(....)) {
if (!JS_IsExceptionPending(cx)) {
// This is an "uncatchable exception" like a slow script
// interrupt or worker termination. Generally,
// SpiderMonkey does not do this on its own; embeddings
// have to trigger it explicitly. Handle it however you
// want.
} else {
// Use JS_GetPendingException, then JS_ClearPendingException,
then report the exception however you want.
}
}
You can use js::ErrorReport and its init() method to generate a
JSErrorReport and then do whatever with it.
-Boris