clean up log.error (#1109)

This commit is contained in:
Inna Harper 2025-07-09 11:15:14 +01:00 • committed by GitHub
commit 4fee123e72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,7 +16,7 @@ This document contains critical information about working with this codebase. Fo
- Public APIs must have docstrings
- Functions must be focused and small
- Follow existing patterns exactly
- Line length: 88 chars maximum
- Line length: 120 chars maximum
3. Testing Requirements
- Framework: `uv run --frozen pytest`
@ -116,3 +116,15 @@ This document contains critical information about working with this codebase. Fo
- Follow existing patterns
- Document public APIs
- Test thoroughly
## Exception Handling
- **Always use `logger.exception()` instead of `logger.error()` when catching exceptions**
- Don't include the exception in the message: `logger.exception("Failed")` not `logger.exception(f"Failed: {e}")`
- **Catch specific exceptions** where possible:
- File ops: `except (OSError, PermissionError):`
- JSON: `except json.JSONDecodeError:`
- Network: `except (ConnectionError, TimeoutError):`
- **Only catch `Exception` for**:
- Top-level handlers that must not crash
- Cleanup blocks (log at debug level)