Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pygobject pygobject
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 278
    • Issues 278
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • pygobjectpygobject
  • Issues
  • #199

Closed
Open
Created Apr 13, 2018 by Kai Willadsen@kaiwDeveloper

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 err.domain attribute.

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.

Edited Apr 14, 2018 by Christoph Reiter
Assignee
Assign to
Time tracking