GNOME Bugzilla – Bug 618200
Log errors that occur in callbacks
Last modified: 2010-05-13 14:13:24 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.
Created attachment 160669 [details] [review] Log errors that occur in callbacks
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.
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.
(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.
Attachment 160669 [details] pushed as d8636c8 - Log errors that occur in callbacks