Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Define own hierarchy of exceptions? #248

Copy link
Copy link
Open
@tomschr

Description

@tomschr
Issue body actions

Situation

Currently, our code catches an invalid version and raise an exception. This is good. However, the exceptions are usually builtin exceptions like TypeError, ValueError, or AttributeError.

This could make it likely, that an semver exceptions are "hidden". It cannot explicitly be checked that a TypeError is coming from semver and not from another, unrelated third party library.

Proposal

This part could be solved by introducing our own hierarchy of exceptions like so:

class InvalidVersionError(ValueError):
    """Raised by invalid parts in a semver version"""

The nice thing about this approach is, any old code would still work (as InvalidVersionError is derived from ValueError).

@python-semver/reviewers would that be an option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesignIdeas, suggestions, musings about design questionsIdeas, suggestions, musings about design questionsEnhancementNot a bug, but increases or improves in value, quality, desirability, or attractivenessNot a bug, but increases or improves in value, quality, desirability, or attractivenessQuestionUnclear or open issue subject for debateUnclear or open issue subject for debateRelease_3.x.yOnly for the major release 3Only for the major release 3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.