This repository was archived by the owner on Jun 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 11import traceback
2- from typing import AsyncGenerator
32
43import structlog
5- from fastapi import APIRouter , Depends , FastAPI , Request
4+ from fastapi import APIRouter , FastAPI , Request
65from fastapi .middleware .cors import CORSMiddleware
76from fastapi .responses import JSONResponse
87from starlette .middleware .errors import ServerErrorMiddleware
1918
2019logger = structlog .get_logger ("codegate" )
2120
21+
2222async def custom_error_handler (request , exc : Exception ):
2323 """This is a Middleware to handle exceptions and log them."""
2424 # Capture the stack trace
@@ -27,6 +27,7 @@ async def custom_error_handler(request, exc: Exception):
2727 logger .error (traceback .print_list (extracted_traceback [- 3 :]))
2828 return JSONResponse ({"error" : str (exc )}, status_code = 500 )
2929
30+
3031def init_app (pipeline_factory : PipelineFactory ) -> FastAPI :
3132 """Create the FastAPI application."""
3233 app = FastAPI (
@@ -96,4 +97,4 @@ async def health_check():
9697 app .include_router (system_router )
9798 app .include_router (dashboard_router )
9899
99- return app
100+ return app
You can’t perform that action at this time.
0 commit comments