clean-python-error-handling
Installation
SKILL.md
Clean Python Error Handling
Error handling is part of the public behavior. Keep normal flow readable, preserve context, and make recoverable failures explicit.
EH1: Raise Useful Exceptions
Raise exception objects with useful context. Choose built-in exceptions or project-specific subclasses that match the failure.
# Bad
raise Exception("User not found")
# Good
raise UserNotFoundError(f"User not found: {user_id}")
When wrapping an exception, preserve the cause.