GNOME Bugzilla – Bug 602449
errors from introspected functions should throw the GLib.Error
Last modified: 2009-11-19 21:05:27 UTC
Many methods return GErrors with domain and code set to useful things that the caller can interpret. But gjs throws that info away. (Even when the code isn't useful, the original GError's message may at least be user-presentable, while the gjs-ified version with "Error invoking Blah.blah" prepended to it really isn't.) So, when an introspected method returns a GError, gjs should just wrap it and throw the GLib.Error rather than creating a generic js Error. (Javascript allows throwing any object, not just subclasses of Error. And most code doesn't look at anything besides the error's 'message' property, and GLib.Error has one of those too, so callers shouldn't even notice the switcheroo. If we wanted to be paranoid we could throw a plain Error with a "gerror" property added to it or something though I guess.) If this makes sense I can write a patch.
Throwing a GLib.Error with a message (and code) property seems sane to me.
*** This bug has been marked as a duplicate of bug 591480 ***