OperationCanceledExceptionExtensions Class

Provides ThrowNew extension methods for OperationCanceledException.

public static class OperationCanceledExceptionExtensions

Remarks

Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in OperationCanceledException.ThrowNew(message).

The first method returns no value. Call it as a statement.

The second method has a type parameter, which is also its return type. Call it where the code needs an expression of that type.

See also

Methods

NameDescription
OperationCanceledException.ThrowNew()Throws a new OperationCanceledException.
OperationCanceledException.ThrowNew(string?)Throws a new OperationCanceledException.
OperationCanceledException.ThrowNew(string?, Exception?)Throws a new OperationCanceledException.
OperationCanceledException.ThrowNew(string?, Exception?, CancellationToken)Throws a new OperationCanceledException.
OperationCanceledException.ThrowNew(string?, CancellationToken)Throws a new OperationCanceledException.
OperationCanceledException.ThrowNew(CancellationToken)Throws a new OperationCanceledException.
OperationCanceledException.ThrowNew<T>()Throws a new OperationCanceledException, where the code needs an expression of type T.
OperationCanceledException.ThrowNew<T>(string?)Throws a new OperationCanceledException, where the code needs an expression of type T.
OperationCanceledException.ThrowNew<T>(string?, Exception?)Throws a new OperationCanceledException, where the code needs an expression of type T.
OperationCanceledException.ThrowNew<T>(string?, Exception?, CancellationToken)Throws a new OperationCanceledException, where the code needs an expression of type T.
OperationCanceledException.ThrowNew<T>(string?, CancellationToken)Throws a new OperationCanceledException, where the code needs an expression of type T.
OperationCanceledException.ThrowNew<T>(CancellationToken)Throws a new OperationCanceledException, where the code needs an expression of type T.

OperationCanceledException.ThrowNew overloads

OperationCanceledException.ThrowNew()

extension(OperationCanceledException)
{
    public static void ThrowNew()
}

OperationCanceledException.ThrowNew(string?)

extension(OperationCanceledException)
{
    public static void ThrowNew(string? message)
}
Parameters
message string?
A String that describes the error.

OperationCanceledException.ThrowNew(string?, Exception?)

extension(OperationCanceledException)
{
    public static void ThrowNew(string? message, Exception? innerException)
}
Parameters
message string?
The error message that explains the reason for the exception.
innerException Exception?
The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

OperationCanceledException.ThrowNew(string?, Exception?, CancellationToken)

extension(OperationCanceledException)
{
    public static void ThrowNew(string? message, Exception? innerException, CancellationToken token)
}
Parameters
message string?
The error message that explains the reason for the exception.
innerException Exception?
The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.
token CancellationToken
A cancellation token associated with the operation that was canceled.

OperationCanceledException.ThrowNew(string?, CancellationToken)

extension(OperationCanceledException)
{
    public static void ThrowNew(string? message, CancellationToken token)
}
Parameters
message string?
The error message that explains the reason for the exception.
token CancellationToken
A cancellation token associated with the operation that was canceled.

OperationCanceledException.ThrowNew(CancellationToken)

extension(OperationCanceledException)
{
    public static void ThrowNew(CancellationToken token)
}
Parameters
token CancellationToken
A cancellation token associated with the operation that was canceled.

OperationCanceledException.ThrowNew<T>()

Throws a new OperationCanceledException, where the code needs an expression of type T.

extension(OperationCanceledException)
{
    public static T ThrowNew<T>()
}
Type parameters
T
The type of the expression.
Returns

T This method does not return.

OperationCanceledException.ThrowNew<T>(string?)

Throws a new OperationCanceledException, where the code needs an expression of type T.

extension(OperationCanceledException)
{
    public static T ThrowNew<T>(string? message)
}
Type parameters
T
The type of the expression.
Parameters
message string?
A String that describes the error.
Returns

T This method does not return.

OperationCanceledException.ThrowNew<T>(string?, Exception?)

Throws a new OperationCanceledException, where the code needs an expression of type T.

extension(OperationCanceledException)
{
    public static T ThrowNew<T>(string? message, Exception? innerException)
}
Type parameters
T
The type of the expression.
Parameters
message string?
The error message that explains the reason for the exception.
innerException Exception?
The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.
Returns

T This method does not return.

OperationCanceledException.ThrowNew<T>(string?, Exception?, CancellationToken)

Throws a new OperationCanceledException, where the code needs an expression of type T.

extension(OperationCanceledException)
{
    public static T ThrowNew<T>(string? message, Exception? innerException, CancellationToken token)
}
Type parameters
T
The type of the expression.
Parameters
message string?
The error message that explains the reason for the exception.
innerException Exception?
The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.
token CancellationToken
A cancellation token associated with the operation that was canceled.
Returns

T This method does not return.

OperationCanceledException.ThrowNew<T>(string?, CancellationToken)

Throws a new OperationCanceledException, where the code needs an expression of type T.

extension(OperationCanceledException)
{
    public static T ThrowNew<T>(string? message, CancellationToken token)
}
Type parameters
T
The type of the expression.
Parameters
message string?
The error message that explains the reason for the exception.
token CancellationToken
A cancellation token associated with the operation that was canceled.
Returns

T This method does not return.

OperationCanceledException.ThrowNew<T>(CancellationToken)

Throws a new OperationCanceledException, where the code needs an expression of type T.

extension(OperationCanceledException)
{
    public static T ThrowNew<T>(CancellationToken token)
}
Type parameters
T
The type of the expression.
Parameters
token CancellationToken
A cancellation token associated with the operation that was canceled.
Returns

T This method does not return.