Base Module

Platform-agnostic error handling framework / handlers.

class cli_command_parser.error_handling.base.ErrorHandler[source]

Bases: object

exc_handler_map: dict[Type[BaseException], Handler]
register(handler: Callable[[E], bool | int | None], *exceptions: Type[E])[source]
unregister(*exceptions: Type[BaseException])[source]
__call__(*exceptions: Type[BaseException])[source]
classmethod cls_handler(*exceptions: Type[E])[source]
iter_handlers(exc_type: Type[BaseException], exc: BaseException) Iterator[Callable[[E], bool | int | None]][source]
copy() ErrorHandler[source]
class cli_command_parser.error_handling.base.NullErrorHandler[source]

Bases: object

class cli_command_parser.error_handling.base.Handler(exc_cls: Type[BaseException], handler: Callable[[E], bool | int | None])[source]

Bases: object

Wrapper around an exception class and the handler for it to facilitate sorting to select the most specific handler for a given exception.

exc_cls
handler
cli_command_parser.error_handling.base.error_handler: ErrorHandler = <ErrorHandler[handlers=2]>

Default base ErrorHandler

cli_command_parser.error_handling.base.no_exit_handler: ErrorHandler = <ErrorHandler[handlers=2]>

An ErrorHandler that does not call sys.exit() for CommandParserExceptions

cli_command_parser.error_handling.base.extended_error_handler: ErrorHandler = <ErrorHandler[handlers=1]>

The default ErrorHandler (extends error_handler)