Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shared_error_handler-1.0.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shared_error_handler-1.0.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file shared_error_handler-1.0.0.tar.gz.

File metadata

  • Download URL: shared_error_handler-1.0.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for shared_error_handler-1.0.0.tar.gz
Algorithm Hash digest
SHA256 425cf6b0b71122f8d8a1461e9a106229aeae1661a0512f2f88220b57ca3648f1
MD5 2dbc173b1e81a74bf5099d6032254bd3
BLAKE2b-256 e1a7cd02509203d79a9f21621be57e2380391af040d9116b745424fe6646990f

See more details on using hashes here.

File details

Details for the file shared_error_handler-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for shared_error_handler-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3df0084a9da688c7585eca61dd2a428e74bf68794dc529f8ea766fb9640245c9
MD5 1e401b817284f4069d914aff1ca41097
BLAKE2b-256 1589eb81bee56ae901e204973deebee2f63a3b31475e802b0c2cc8adbe095b5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page