fastapi_middleware_toolkit.error_handlers

Global error handling middleware for FastAPI applications.

Extracted from GridFlow backend/src/middleware/error_handler.py

Attributes

Functions

setup_error_handlers(→ None)

Setup global error handlers for the FastAPI application.

Module Contents

fastapi_middleware_toolkit.error_handlers.logger
fastapi_middleware_toolkit.error_handlers.setup_error_handlers(app: fastapi.FastAPI, custom_exception_class: Type[Exception] | None = None) None

Setup global error handlers for the FastAPI application.

Args:

app: FastAPI application instance custom_exception_class: Optional custom exception class to handle

Example:
>>> from fastapi import FastAPI
>>> from python_app_exceptions import BaseApplicationException
>>> app = FastAPI()
>>> setup_error_handlers(app, BaseApplicationException)