You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/06/29 15:19:57 UTC

[airflow] 12/45: Removing magic numbers from exceptions (#23997)

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 412c1524ad804eed1a7aef6f445c34bf97457e28
Author: Bernardo Couto <35...@users.noreply.github.com>
AuthorDate: Tue May 31 08:59:52 2022 -0300

    Removing magic numbers from exceptions (#23997)
    
    * Removing magic numbers from exceptions
    
    * Running pre-commit
    
    (cherry picked from commit 375673aa3cebf6889f403ac1577cffe0c33c1ae7)
---
 airflow/exceptions.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/airflow/exceptions.py b/airflow/exceptions.py
index bfb5835fda..6a8eed35a3 100644
--- a/airflow/exceptions.py
+++ b/airflow/exceptions.py
@@ -21,6 +21,7 @@
 """Exceptions used by Airflow"""
 import datetime
 import warnings
+from http import HTTPStatus
 from typing import Any, Dict, List, NamedTuple, Optional, Sized
 
 
@@ -31,19 +32,19 @@ class AirflowException(Exception):
     Each custom exception should be derived from this class.
     """
 
-    status_code = 500
+    status_code = HTTPStatus.INTERNAL_SERVER_ERROR
 
 
 class AirflowBadRequest(AirflowException):
     """Raise when the application or server cannot handle the request."""
 
-    status_code = 400
+    status_code = HTTPStatus.BAD_REQUEST
 
 
 class AirflowNotFoundException(AirflowException):
     """Raise when the requested object/resource is not available in the system."""
 
-    status_code = 404
+    status_code = HTTPStatus.NOT_FOUND
 
 
 class AirflowConfigException(AirflowException):