If we made [AirflowNotFound](https://github.com/apache/airflow/blob/master/airflow/exceptions.py#L43-L46) inherit from [connextion.NotFound](https://github.com/apache/airflow/blob/master/airflow/api_connexion/exceptions.py#L75-L83) this code could be a simpler [here](https://github.com/apache/airflow/blob/690e80b82b12ab1d7232d6f02ea6bddd1d71750c/airflow/api_connexion/endpoints/task_instance_endpoint.py#L290-L297).


_Originally posted by @ashb in https://github.com/apache/airflow/pull/11335#discussion_r511863077_
airflow/exceptions.py
"""Raise when multiple values are found for the same conn_id"""
class TaskDeferred(BaseException):
    """
    Special exception raised to signal that the operator it was raised from
    wishes to defer until a trigger fires.
    """
    def __init__(
        self,
        *,
        trigger,
        method_name: str,
        kwargs: Optional[Dict[str, Any]] = None,
        timeout: Optional[datetime.timedelta] = None,
    ):
        super().__init__()
        self.trigger = trigger
        self.method_name = method_name
        self.kwargs = kwargs
        self.timeout = timeout
        
        if self.timeout is not None and not hasattr(self.timeout, "total_seconds"):
            raise ValueError("Timeout value must be a timedelta")
    def __repr__(self) -> str:
        return f"<TaskDeferred trigger={self.trigger} method={self.method_name}>"
class TaskDeferralError(AirflowException):
    """Raised when a task failed during deferral for some reason."""