henry3260 commented on code in PR #63801:
URL: https://github.com/apache/airflow/pull/63801#discussion_r3064027783
##########
airflow-core/src/airflow/api_fastapi/common/exceptions.py:
##########
@@ -122,4 +123,101 @@ def exception_handler(self, request: Request, exc:
DeserializationError):
)
+class ExecutionHTTPException(HTTPException):
+ """
+ HTTPException subclass used by Execution API.
+
+ Enforces consistent error response format containing `reason` and
`message` keys.
+ """
+
+ def __init__(
+ self,
+ status_code: int,
+ *,
+ reason: str,
+ message: str,
+ extra: dict[str, Any] | None = None,
+ headers: dict[str, str] | None = None,
+ ) -> None:
+ """
+ Initialize with explicit reason/message and optional extra fields.
+
+ detail will be constructed as a dict: {"reason": reason, "message":
message, **extra}
+ """
+ detail: dict[str, Any] = {"reason": reason, "message": message}
+ if extra:
+ # Do not allow overriding reason/message through extra
accidentally.
+ for k, v in extra.items():
+ if k not in ("reason", "message"):
+ detail[k] = v
+ super().__init__(status_code=status_code, detail=detail,
headers=headers)
+
+
ERROR_HANDLERS: list[BaseErrorHandler] = [_UniqueConstraintErrorHandler(),
DagErrorHandler()]
+
+
+# --------------------
+# Global exception normalization utilities and registration
+# --------------------
Review Comment:
Sorry I didn't notice this
--
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]