Registry / observability / tidyexc

tidyexc

JSON →
library0.10.0pypypi✓ verified 88d ago

tidyexc provides an exception class inspired by the tidyverse style guide for Python. It supports adding structured information to exceptions and formatting tracebacks in a clean, readable way. Current version is 0.10.0, released periodically.

pip install tidyexc
INSTALL
IMPORT
SIG · TIDYEXC
T
tidyexc
observabilitypythonv0.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Error
✓ from tidyexc import Error
✗ from tidyexc import TidyError
The main exception class is named Error, not TidyError.
format_exception_chain
✓ from tidyexc import format_exception_chain
✗ from tidyexc import format_exc
format_exception_chain is the correct public function; format_exc is internal.
add_info
✓ from tidyexc import add_info
✗ from tidyexc import add_info_to_exception
The function is add_info, not add_info_to_exception.
only_raise
✓ from tidyexc import only_raise
✗ from tidyexc import raise_only
The context manager is only_raise, not raise_only.

Create a custom exception with tidyexc and attach additional context.

from tidyexc import Error, add_info try: raise Error('Something went wrong') except Error as e: add_info(e, user_id=42) raise
Debug
Known issues
breakingIn version 0.8.0, the internal use of format_exc() was removed. Code relying on that internal function must switch to format_exception_chain.
fix
Use formatexceptionchain from tidyexc instead of any internal format_exc.
affects: >=0.8.0
gotchaThe Error class is not a subclass of BaseException, but a plain object that wraps exceptions. Catching Exception does not catch tidyexc errors.
fix
Catch tidyexc.Error specifically, or use except Exception as e: only if the error is raised via raise Error('msg').
affects: all
deprecatedIn version 0.7.0, add_info started supporting recursive calls. Older patterns that manually handle nested exceptions may break.
fix
Upgrade to >=0.7.0 and use add_info recursively.
affects: <0.7.0
gotchaThe put_info() function was added in version 0.8.0. It may conflict with add_info if used incorrectly.
fix
Use put_info to attach information without modifying the exception chain.
affects: >=0.8.0
breakingIn version 0.5.1, the dotmap dependency was replaced with a non-recursive alternative. Code relying on dotmap's recursive behavior for nested attribute access may break.
fix
Refactor code to not depend on recursive attribute access on info dicts.
affects: >=0.5.1
Errors
Common errors & fixes
NameError: name 'TidyError' is not defined
Mis-import: tidyexc exports Error, not TidyError.
fix
Replace 'from tidyexc import TidyError' with 'from tidyexc import Error'.
TypeError: exceptions must derive from BaseException
Raising a tidyexc Error directly without wrapping it in a regular exception.
fix
Raise an instance of a builtin exception (e.g., RuntimeError) and attach tidyexc.Error via add_info, or use only_raise context manager.
AttributeError: module 'tidyexc' has no attribute 'format_exc'
Using internal name; public function is format_exception_chain.
fix
Replace tidyexc.format_exc with tidyexc.format_exception_chain.
Upgrade
Version history
0.10.0latest on PyPI · released Dec 15, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
tidyexc — pip install tidyexc · libregistry