def METHOD_NAME(self, env: Environment, ex: Exception) -> FailureEvent:
    if isinstance(ex, ClientError):
        error, cause = self._error_cause_from_client_error(ex)
        error_name = CustomErrorName(error)
        return FailureEvent(
            error_name=error_name,
            event_type=HistoryEventType.TaskFailed,
            event_details=EventDetails(
                taskFailedEventDetails=TaskFailedEventDetails(
                    error=error,
                    cause=cause,
                    resource=self._get_sfn_resource(),
                    resourceType=self._get_sfn_resource_type(),
                )
            ),
        )
    else:
        return FailureEvent(
            error_name=CustomErrorName(self._ERROR_NAME_AWS),
            event_type=HistoryEventType.TaskFailed,
            event_details=EventDetails(
                taskFailedEventDetails=TaskFailedEventDetails(
                    error=self._ERROR_NAME_AWS,
                    cause=str(ex),  # TODO: update to report expected cause.
                    resource=self._get_sfn_resource(),
                    resourceType=self._get_sfn_resource_type(),
                )
            ),
        )