Skip to main content

An exception class inspired by the tidyverse style guide.

Project description

Last release Python version Documentation Test status Test coverage Last commit

TidyExc provides an exception base class that makes it easy to raise rich, helpful exceptions:

  • Rich: Instead of simply storing an error message, TidyExc exceptions separately store parameters and message templates. This separation makes it easier for exception handling code to access information describing the error and to respond accordingly.

  • Helpful: TidyExc is inspired by the error message conventions promoted by the tidyverse style guide. Briefly, these conventions state that an error message should consist of a brief statement of the problem, followed by a bullet-point list of relevant contextual information. The bullet-point format makes it easy to include lots of detail, without the detail becoming overwhelming.

The following example shows TidyExc in action:

>>> from tidyexc import Error
>>> class CheeseShopError(Error):
...     pass
...
>>> err = CheeseShopError(
...         product_name="Red Leicester",
...         num_requested=1,
...         num_available=0,
... )
>>> err.brief = "insufficient inventory to process request"
>>> err.info += "{num_requested} {product_name} requested"
>>> err.blame += "{num_available} available"
>>> raise err
Traceback (most recent call last):
  ...
CheeseShopError: insufficient inventory to process request
• 1 Red Leicester requested
✖ 0 available

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tidyexc-0.10.0.tar.gz (21.0 kB view hashes)

Uploaded source

Built Distribution

tidyexc-0.10.0-py3-none-any.whl (10.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page