Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
pygobject
pygobject
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 243
    • Issues 243
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 12
    • Merge Requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Members
    • Members
  • 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
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None