except_hook
Intercepts and formats unhandled exceptions to provide enhanced traceback output, optionally using Rich for pretty-printing or filtering internal library frames from Typer and Click. It falls back to the original system exception hook if standard tracebacks are requested or if pretty exceptions are disabled.
def except_hook(
exc_type: type[BaseException],
exc_value: BaseException,
tb: TracebackType | None
) - > None
Handles uncaught exceptions by rendering a formatted, user-friendly traceback that optionally filters out internal library frames from Typer and Click. It falls back to the standard system exception hook if pretty exceptions are disabled or if the environment variable TYPER_STANDARD_TRACEBACK is set.
Parameters
| Name | Type | Description |
|---|---|---|
| exc_type | type[BaseException] | The class of the exception being handled. |
| exc_value | BaseException | The instance of the exception that was raised, which may contain developer-specific configuration for formatting. |
| tb | `TracebackType | None` |
Returns
| Type | Description |
|---|---|
None | Nothing; the output is printed directly to the standard error stream. |