Task.FromException method (1 of 2)

Creates a Task that is completed with a specified exception.

public static Task FromException(Exception exception)
parameter description
exception The exception with which to complete the task.

Return Value

The faulted task.

See Also


Task.FromException<TResult> method (2 of 2)

Creates a Task that is completed with a specified exception.

public static Task<TResult> FromException<TResult>(Exception exception)
parameter description
TResult The type of the result returned by the task.
exception The exception with which to complete the task.

Return Value

The faulted task.

See Also