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 1
1
import traceback
2
- from typing import AsyncGenerator
3
2
4
3
import structlog
5
- from fastapi import APIRouter , Depends , FastAPI , Request
4
+ from fastapi import APIRouter , FastAPI , Request
6
5
from fastapi .middleware .cors import CORSMiddleware
7
6
from fastapi .responses import JSONResponse
8
7
from starlette .middleware .errors import ServerErrorMiddleware
19
18
20
19
logger = structlog .get_logger ("codegate" )
21
20
21
+
22
22
async def custom_error_handler (request , exc : Exception ):
23
23
"""This is a Middleware to handle exceptions and log them."""
24
24
# Capture the stack trace
@@ -27,6 +27,7 @@ async def custom_error_handler(request, exc: Exception):
27
27
logger .error (traceback .print_list (extracted_traceback [- 3 :]))
28
28
return JSONResponse ({"error" : str (exc )}, status_code = 500 )
29
29
30
+
30
31
def init_app (pipeline_factory : PipelineFactory ) -> FastAPI :
31
32
"""Create the FastAPI application."""
32
33
app = FastAPI (
@@ -96,4 +97,4 @@ async def health_check():
96
97
app .include_router (system_router )
97
98
app .include_router (dashboard_router )
98
99
99
- return app
100
+ return app
You can’t perform that action at this time.
0 commit comments