jason810496 commented on code in PR #67206:
URL: https://github.com/apache/airflow/pull/67206#discussion_r3305028328
##########
airflow-core/src/airflow/api_fastapi/execution_api/app.py:
##########
@@ -271,6 +272,19 @@ def handle_exceptions(request: Request, exc: Exception):
content["correlation-id"] = correlation_id
return JSONResponse(status_code=500, content=content)
+ @app.exception_handler(SQLAlchemyError)
+ def handle_database_exceptions(request: Request, exc: SQLAlchemyError):
+ logger.exception(
+ "Database error handling request",
+ path=request.url.path,
+ method=request.method,
+ exc_info=(type(exc), exc, exc.__traceback__),
+ )
+ content: dict[str, str] = {"detail": "Database error occurred"}
+ if correlation_id := request.headers.get("correlation-id"):
+ content["correlation-id"] = correlation_id
+ return JSONResponse(status_code=500, content=content)
Review Comment:
It would be be better to follow the convention in
https://github.com/apache/airflow/blob/0120ba7fd5be8b6d5e7e4184209fb0479127f2d8/airflow-core/src/airflow/api_fastapi/common/exceptions.py#L36-L126
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]