Compartilhar via


TaskFailedException.IsCausedByException<T> Method

Definition

Caution

Use the FailureDetails property and its IsCausedBy<T>() method

Returns true if the task failure was provided by the specified exception type.

[System.Obsolete("Use the FailureDetails property and its IsCausedBy<T>() method")]
public bool IsCausedByException<T> () where T : Exception;
[<System.Obsolete("Use the FailureDetails property and its IsCausedBy<T>() method")>]
member this.IsCausedByException : unit -> bool (requires 'T :> Exception)
Public Function IsCausedByException(Of T As Exception) () As Boolean

Type Parameters

T

The type of exception to test against.

Returns

Returns true if the FailureDetails's ErrorType value matches T; false otherwise.

Attributes

Remarks

This method allows checking if a task failed due to an exception of a specific type. The comparison relies on a string comparison of the full type name (e.g., "System.InvalidOperationException") and therefore doesn't support base types.

Applies to