hooks.exceptions module

Provides exception hooking functionality.

class hooks.exceptions._ExceptHooks[source]

Bases: hooks.base._HookBase

List class that stores callbacks to be called on an exception.

print_exception(exctype=None, value=None, trace_back=None, callbacks=True)[source]

Called when an exception is raised.

This method hooks sys.excepthook to log all exceptions and call registered callbacks with the provided arguments.

@hooks.exceptions.ExceptHook[source]

Bases: hooks.base._HookDecorator

Fired when an exception is raised.

The decorated function is passed the following parameters whe an exception is raised:

Parameters:
from hooks.exceptions import ExceptHook

@ExceptHook
def exception_callback(exc_type, value, trace_back):
    # Code...

See also

sys.excepthook

hooks.exceptions.except_hooks

The singleton object of the _ExceptHooks class.