diff --git a/providers/src/airflow/providers/http/exceptions.py b/providers/src/airflow/providers/http/exceptions.py index 57c440a691113..1f20b5249e109 100644 --- a/providers/src/airflow/providers/http/exceptions.py +++ b/providers/src/airflow/providers/http/exceptions.py @@ -18,5 +18,8 @@ from airflow.exceptions import AirflowException +class HttpErrorException(AirflowException): + """Exception raised for HTTP error in Http hook.""" + class HttpMethodException(AirflowException): """Exception raised for invalid HTTP methods in Http hook.""" diff --git a/providers/src/airflow/providers/http/hooks/http.py b/providers/src/airflow/providers/http/hooks/http.py index 1afd1396874cd..76c192c7a6e18 100644 --- a/providers/src/airflow/providers/http/hooks/http.py +++ b/providers/src/airflow/providers/http/hooks/http.py @@ -32,7 +32,7 @@ from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook -from airflow.providers.http.exceptions import HttpMethodException +from airflow.providers.http.exceptions import HttpErrorException, HttpMethodException if TYPE_CHECKING: from aiohttp.client_reqrep import ClientResponse @@ -452,9 +452,7 @@ async def run( self.log.exception("HTTP error with status: %s", e.status) # In this case, the user probably made a mistake. # Don't retry. - raise AirflowException(f"{e.status}:{e.message}") - else: - await asyncio.sleep(self.retry_delay) + raise HttpErrorException(f"{e.status}:{e.message}") else: return response