Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define own hierarchy of exceptions? #248

Open
tomschr opened this issue May 7, 2020 · 0 comments
Open

Define own hierarchy of exceptions? #248

tomschr opened this issue May 7, 2020 · 0 comments
Labels
Design Ideas, suggestions, musings about design questions Enhancement Not a bug, but increases or improves in value, quality, desirability, or attractiveness Question Unclear or open issue subject for debate Release_3.x.y Only for the major release 3
Projects

Comments

@tomschr
Copy link
Member

tomschr commented May 7, 2020

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?

@tomschr tomschr added the Question Unclear or open issue subject for debate label May 7, 2020
@tomschr tomschr added the Enhancement Not a bug, but increases or improves in value, quality, desirability, or attractiveness label May 14, 2020
@tomschr tomschr added this to To do in Release 3 via automation Oct 26, 2020
@tomschr tomschr added the Release_3.x.y Only for the major release 3 label Oct 26, 2020
@tomschr tomschr mentioned this issue Nov 5, 2020
4 tasks
@tomschr tomschr added the Design Ideas, suggestions, musings about design questions label Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Ideas, suggestions, musings about design questions Enhancement Not a bug, but increases or improves in value, quality, desirability, or attractiveness Question Unclear or open issue subject for debate Release_3.x.y Only for the major release 3
Projects
No open projects
Release 3
  
To do
Development

No branches or pull requests

1 participant