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

Add root exception for all pint errors #1321

Merged
merged 1 commit into from Aug 3, 2021
Merged

Add root exception for all pint errors #1321

merged 1 commit into from Aug 3, 2021

Conversation

c-w
Copy link
Contributor

@c-w c-w commented May 28, 2021

Many libraries follow the pattern where there's a single root exception that can be caught to identify any exception the library throws which makes it very easy to isolate issues related to the library. This pull request adds such a root exception.

Usage example:

import pint
ureg = pint.UnitRegistry()

try:
  # do something involving ureg
except pint.PintError:
  # here we know for sure that the error came from pint
  • Closes # (insert issue number)
    • This is a developer ergonomics improvement that came to mind while working with the library so I didn't open an issue for it.
  • Executed pre-commit run --all-files with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
    • I didn't see any existing references to exception handling in the docs so I didn't add anything related to the new root exception.
  • Added an entry to the CHANGES file

@hgrecco
Copy link
Owner

hgrecco commented May 28, 2021

I think this a good idea. What do you think @jules-ch ?

@jules-ch
Copy link
Collaborator

jules-ch commented Aug 2, 2021

That's a good idea ! 👍

@hgrecco hgrecco merged commit 1d56653 into hgrecco:master Aug 3, 2021
@c-w c-w deleted the root-exception branch August 3, 2021 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants