Skip to content

Add root exception for all pint errors - #1321

Merged
hgrecco merged 1 commit into
hgrecco:masterfrom
c-w:root-exception
Aug 3, 2021
Merged

hgrecco merged 1 commit into
hgrecco:masterfrom
c-w:root-exception

Conversation

@c-w

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

Copy link
Copy Markdown
Contributor

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

hgrecco commented May 28, 2021

Copy link
Copy Markdown
Owner

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

@jules-ch

jules-ch commented Aug 2, 2021

Copy link
Copy Markdown
Collaborator

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.

3 participants