Centralized, reusable error-handling and structured-logging package for Python/FastAPI applications.
Project description
shared-error-handler
Centralized, reusable error-handling and structured-logging package for Python/FastAPI applications.
Install
pip install shared-error-handler
Quick start
from shared_error_handler import setup_error_handling, get_logger
from fastapi import FastAPI
app = FastAPI()
setup_error_handling(app, service_name="my-api")
logger = get_logger(__name__, color=True)
logger.info("Ready")
Logger
from shared_error_handler.logger import get_logger
logger = get_logger(__name__) # structured JSON (production)
logger = get_logger(__name__, color=True) # colored terminal (dev)
Exceptions
from shared_error_handler import NotFoundError, ValidationError, ForbiddenError
raise NotFoundError(developer_message="User not found", context={"id": uid})
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters