configure exception handlers

main
MrWaradana 3 weeks ago
parent 783841d37e
commit 886fdaf3d2

@ -129,6 +129,9 @@ def configure_logging():
access_logger.handlers = []
access_logger.propagate = False
# set uvicorn access log level to warning
logging.getLogger("uvicorn.access").setLevel(logging.WARNING)
# sometimes the slack client can be too verbose
logging.getLogger("slack_sdk.web.base_client").setLevel(logging.CRITICAL)

@ -40,19 +40,18 @@ log = logging.getLogger(__name__)
# we configure the logging level and format
configure_logging()
# we define the exception handlers
exception_handlers = {Exception: handle_exception}
# we create the ASGI for the app
app = FastAPI(exception_handlers=exception_handlers, openapi_url="", title="LCCA API",
app = FastAPI(openapi_url="", title="LCCA API",
description="Welcome to LCCA's API documentation!",
version="0.1.0")
app.state.limiter = limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
# we define the exception handlers
app.add_exception_handler(Exception, handle_exception)
app.add_exception_handler(HTTPException, handle_exception)
app.add_exception_handler(StarletteHTTPException, handle_exception)
app.add_exception_handler(RequestValidationError, handle_exception)
app.add_exception_handler(SQLAlchemyError, handle_exception)
app.add_middleware(GZipMiddleware, minimum_size=2000)
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
from src.context import set_request_id, reset_request_id, get_request_id

Loading…
Cancel
Save