After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 618200 - Log errors that occur in callbacks
Log errors that occur in callbacks
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2010-05-09 20:27 UTC by Owen Taylor
Modified: 2010-05-13 14:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Log errors that occur in callbacks (1.66 KB, patch)
2010-05-09 20:27 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2010-05-09 20:27:14 UTC
If an exception occurs in a callback, instead of leaving the exception
set in the JS context (which often result in the exception
disappearing off into the ether), log and clear it.
Comment 1 Owen Taylor 2010-05-09 20:27:15 UTC
Created attachment 160669 [details] [review]
Log errors that occur in callbacks
Comment 2 Dan Winship 2010-05-10 14:03:57 UTC
This is "if C code calls back into javascript and the javascript throws an exception"?

It seems like if the callback has a GError argument, it would be nice to throw the exception via that.
Comment 3 Colin Walters 2010-05-10 14:39:51 UTC
Review of attachment 160669 [details] [review]:

Looks right.  As far as setting GError * in callbacks - we could add a note to this code to support it later, but honestly that's just a bad design pattern as discussed in another bug.  The GIO pattern is better.
Comment 4 Owen Taylor 2010-05-10 14:44:09 UTC
(In reply to comment #3)
> Review of attachment 160669 [details] [review]:
> 
> Looks right.  As far as setting GError * in callbacks - we could add a note to
> this code to support it later, but honestly that's just a bad design pattern as
> discussed in another bug.  The GIO pattern is better.

That's a different case - GError * in parameters rather than GError ** out parameters.

In terms of setting GError ** out parameters, I guess the questions are:

 -  whether it's OK to 
    g_error_set (error, GJS_ERROR, GJS_ERROR_EXCEPTION_THROWN, "some string"); 
    and hand that back to the caller which has no idea about the error domain.

 - whether to still log the exception (the stack trace wouldn't be stored in the GError)

 - whether any examples actually exist of callbacks taking 
   GError ** out parameters...

Could be left for future need.
Comment 5 Owen Taylor 2010-05-13 14:13:22 UTC
Attachment 160669 [details] pushed as d8636c8 - Log errors that occur in callbacks