Error reporting changes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error reporting changes

Jan de Mooij-2
Hi all,

Just a heads-up: we want to change how exceptions are reported to the
embedding [0].

The current/old behavior: the embedding sets an error reporter callback
(JS_SetErrorReporter), and the engine calls this when it throws an
exception and script doesn't catch it.

The new behavior: the callback will be renamed and will only be used for
warnings. Exceptions will be left on the JSContext and the embedding can
use JS_GetPendingException to get it. A RAII class is useful for this, for
instance see our code for the shell [1] and Gecko [2].

You can test this right now by setting the autoJSAPIOwnsErrorReporting
JSContext option. This option (and the dontReportUncaught option) will also
be removed though.

Please let us know if you have any questions or concerns.

Thanks,
Jan

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1277278
[1]
https://hg.mozilla.org/mozilla-central/file/111970c73823/js/src/shell/js.cpp#l5938
[2]
https://hg.mozilla.org/mozilla-central/file/111970c73823/dom/base/ScriptSettings.cpp#l319
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Error reporting changes

Ehsan Akhgari
On 2016-06-01 1:03 PM, Jan de Mooij wrote:

> Hi all,
>
> Just a heads-up: we want to change how exceptions are reported to the
> embedding [0].
>
> The current/old behavior: the embedding sets an error reporter callback
> (JS_SetErrorReporter), and the engine calls this when it throws an
> exception and script doesn't catch it.
>
> The new behavior: the callback will be renamed and will only be used for
> warnings. Exceptions will be left on the JSContext and the embedding can
> use JS_GetPendingException to get it. A RAII class is useful for this, for
> instance see our code for the shell [1] and Gecko [2].

This sounds great!

Is the plan to provide that RAII class in the public API, out of curiosity?

> You can test this right now by setting the autoJSAPIOwnsErrorReporting
> JSContext option. This option (and the dontReportUncaught option) will also
> be removed though.
>
> Please let us know if you have any questions or concerns.

It would be helpful if these renames and removals can all happen at the
same time so that the embedders notice the behavior change by getting
compiler errors.

Cheers,
Ehsan
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Error reporting changes

Jan de Mooij-2
On Thu, Jun 2, 2016 at 9:43 PM, Ehsan Akhgari <[hidden email]>
wrote:

> Is the plan to provide that RAII class in the public API, out of curiosity?
>

I don't know, each embedder probably wants to handle exceptions
differently. Maybe we could add a default implementation that reports to
stderr, or a class with a virtual method that takes a js::ErrorReport& etc
so you don't have to do that part yourself...


> It would be helpful if these renames and removals can all happen at the
> same time so that the embedders notice the behavior change by getting
> compiler errors.
>

Yes, good idea.

Jan
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine