Signals from ErrorHandler

The lback.core.error_handler.ErrorHandler class is responsible for gracefully handling various application errors and exceptions, generating appropriate HTTP responses. This class emits signals at key moments when error responses are generated, providing critical hooks for centralized error logging, custom error reporting, and integrating with external monitoring and alerting systems.

Signal Name

Description

Arguments (kwargs)

error_handler_initialized

Emitted immediately after the ErrorHandler instance has been successfully initialized.

sender (ErrorHandler): The instance of the error handler.

error_response_generated

Emitted whenever a standard error response (e.g., 404 Not Found, 403 Forbidden, 500 Internal Server Error from explicit handle_500, or custom errors) is generated by the error handler.

sender (ErrorHandler): The error handler instance.<br>``status_code`` (int): The HTTP status code of the generated error response (e.g., 404, 403, 500).<br>``error_message`` (str): A general message describing the error.<br>``request`` (Any, optional): The incoming request object that led to the error, if available.<br>``response`` (Response): The generated HTTP response object.<br>``exception`` (Exception, optional): The exception object if the error originated from an explicit exception (e.g., in handle_500).<br>``allowed_methods`` (list, optional): A list of allowed HTTP methods, specifically for 405 Method Not Allowed errors.

unhandled_exception_response_generated

Emitted specifically when an unhandled exception occurs during request processing, leading to a 500 Internal Server Error response. This signal provides detailed context about the exception.

sender (ErrorHandler): The error handler instance.<br>``status_code`` (int): The HTTP status code (always 500).<br>``exception`` (Exception): The unhandled exception object that occurred.<br>``request`` (Any): The incoming request object during which the exception occurred.<br>``response`` (Response): The generated HTTP response object.