utils
Class info¶
🛈 DocStrings¶
Provides a decorator for exception handling with template support.
error_handler
¶
error_handler(
log_template: str,
catch_exception: type[Exception],
*,
chain_with: type[Exception] | None = None,
hide_internal_trace: bool = True
) -> Callable[[Callable[P, R]], Callable[P, R]]
Decorator that logs function calls and handles exceptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_template
|
str
|
Template string for logging (uses function parameters) |
required |
catch_exception
|
type[Exception]
|
Exception type to catch |
required |
chain_with
|
type[Exception] | None
|
Optional exception type to chain with the caught exception |
None
|
hide_internal_trace
|
bool
|
Whether to hide decorator frames from traceback |
True
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable[P, R]], Callable[P, R]]
|
Decorated function that includes logging and exception handling |