GError-specific logic could be easier
Firstly, if I've missed some more convenient API here, I apologise.
I've just spent the last quite-a-while trying to figure out how to handle matching
GErrors within a specific domain. While the
GError objects themselves helpfully expose
.domain, finding a constant that maps to that turned out to be challenging.
What I ended up with (after reading a bit of the pygobject source) was basically:
try: # do my dodgy unicode-decoding thing except GLib.Error as err: if err.matches(GLib.convert_error_quark(), GLib.ConvertError.ILLEGAL_SEQUENCE): # handle stuff
The main reason that this process ended up being so confusing was that I couldn't find anywhere in Python land where I could reference the string constant in the
IMO, a significant improvement would be to expose the quark and/or domain on the individual
GLib.Error subclasses. Having said that, at that point there's no reason that
matches couldn't just take the enum and do the quark check from that.