Skip to content

Commit 20e5991

Browse files
committed
fixup! fixup! Move out some exceptions to TaskSDK
1 parent 76a0747 commit 20e5991

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

airflow-core/src/airflow/exceptions.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,12 @@
2424
from http import HTTPStatus
2525
from typing import TYPE_CHECKING, NamedTuple
2626

27+
from airflow.sdk.exceptions import AirflowException, AirflowNotFoundException
28+
2729
if TYPE_CHECKING:
2830
from airflow.models import DagRun
2931

3032

31-
class AirflowException(Exception):
32-
"""
33-
Base class for all Airflow's errors.
34-
35-
Each custom exception should be derived from this class.
36-
"""
37-
38-
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
39-
40-
def serialize(self):
41-
cls = self.__class__
42-
return f"{cls.__module__}.{cls.__name__}", (str(self),), {}
43-
44-
4533
class AirflowBadRequest(AirflowException):
4634
"""Raise when the application or server cannot handle the request."""
4735

@@ -52,12 +40,6 @@ class TaskNotFound(AirflowException):
5240
"""Raise when a Task is not available in the system."""
5341

5442

55-
class AirflowNotFoundException(AirflowException):
56-
"""Raise when the requested object/resource is not available in the system."""
57-
58-
status_code = HTTPStatus.NOT_FOUND
59-
60-
6143
class AirflowConfigException(AirflowException):
6244
"""Raise when there is configuration problem."""
6345

@@ -66,10 +48,6 @@ class InvalidStatsNameException(AirflowException):
6648
"""Raise when name of the stats is invalid."""
6749

6850

69-
class AirflowFailException(AirflowException):
70-
"""Raise when the task should be failed without retrying."""
71-
72-
7351
class AirflowOptionalProviderFeatureException(AirflowException):
7452
"""Raise by providers when imports are missing for optional provider features."""
7553

airflow-core/tests/unit/models/test_taskinstance.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@
3535

3636
from airflow import settings
3737
from airflow._shared.timezones import timezone
38-
from airflow.exceptions import (
39-
AirflowException,
40-
AirflowFailException,
41-
AirflowInactiveAssetInInletOrOutletException,
42-
AirflowSkipException,
43-
)
38+
from airflow.exceptions import AirflowException
4439
from airflow.models.asset import AssetActive, AssetAliasModel, AssetEvent, AssetModel
4540
from airflow.models.baseoperator import BaseOperator
4641
from airflow.models.connection import Connection
@@ -69,6 +64,11 @@
6964
from airflow.sdk.definitions.asset import Asset, AssetAlias
7065
from airflow.sdk.definitions.param import process_params
7166
from airflow.sdk.definitions.taskgroup import TaskGroup
67+
from airflow.sdk.exceptions import (
68+
AirflowFailException,
69+
AirflowInactiveAssetInInletOrOutletException,
70+
AirflowSkipException,
71+
)
7272
from airflow.sdk.execution_time.comms import (
7373
AssetEventsResult,
7474
)

0 commit comments

Comments
 (0)