File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import sentry_sdk
22from sentry_sdk .integrations .asgi import SentryAsgiMiddleware
33from starlette .applications import Starlette
4+ from starlette .exceptions import HTTPException
45from starlette .middleware import Middleware
56from starlette .middleware .authentication import AuthenticationMiddleware
67from starlette .middleware .cors import CORSMiddleware
8+ from starlette .requests import Request
9+ from starlette .responses import JSONResponse
710
811from backend import constants
912from backend .authentication import JWTAuthenticationBackend
4750 Middleware (ProtectedDocsMiddleware ),
4851]
4952
50- app = Starlette (routes = create_route_map (), middleware = middleware )
53+
54+ async def http_exception (_request : Request , exc : HTTPException ) -> JSONResponse : # noqa: RUF029
55+ return JSONResponse ({"detail" : exc .detail }, status_code = exc .status_code )
56+
57+
58+ exception_handlers = {HTTPException : http_exception }
59+
60+ app = Starlette (
61+ routes = create_route_map (), middleware = middleware , exception_handlers = exception_handlers
62+ )
5163api .register (app )
You can’t perform that action at this time.
0 commit comments