forked from mtusi2026/mtusi2026lab2
feat-(smoke test passed)
This commit is contained in:
+12
-1
@@ -61,7 +61,18 @@ async def http_exception_handler(request: Request, exc: HTTPException):
|
||||
}
|
||||
|
||||
code = code_map.get(exc.status_code, "internal_error")
|
||||
return create_error_response(message=str(exc.detail), code=code, status_code=exc.status_code, request_id=request_id)
|
||||
response_headers = {"X-Request-Id": request_id}
|
||||
if exc.headers:
|
||||
response_headers.update(exc.headers)
|
||||
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content={"error": {
|
||||
"code": code,
|
||||
"message": str(exc.detail),
|
||||
"request_id": request_id}
|
||||
},
|
||||
headers=response_headers)
|
||||
|
||||
@application.exception_handler(Exception)
|
||||
async def global_exception_handler(request: Request, exc: Exception):
|
||||
|
||||
Reference in New Issue
Block a user