TaskFailedException.IsCausedByException<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.