Class ResultExtension
Reads a use case out loud: OnSuccess / OnSuccessNull / OnSuccessNotNull / OnFailed describe what happens to a FluentResults.Result without the caller writing a single if statement.
Two rules keep that readability honest:
- A method named *Async always returns a Task or a ValueTask, so the caller must await it. Nothing in this class ever blocks on a Task (no .Wait(), no .Result).
- A method NOT named *Async never accepts an asynchronous callback. Passing one is a compile error pointing at the *Async twin, because an async lambda bound to an Action would run as 'async void': fire-and-forget, with nothing awaiting it. Its exception would then surface on a thread pool thread instead of at the caller's await.
- OnSuccess / OnSuccessNull / OnSuccessNotNull / OnFailed run an action and return the original result unchanged, so they never accept a callback returning a result, whose errors would be discarded. Passing one is a compile error pointing at the steps that can fail: Then, EnsureNotNull, Ensure, Compensate and Recover.
The *Async twins take Task-returning callbacks. Adapt a ValueTask-returning call with an async lambda ('async () => await SaveAsync()') or with .AsTask(): a second overload taking Func<ValueTask> would make every async lambda ambiguous.
None of these methods turns an exception thrown by a callback into a failed Result: the exception propagates to the caller. Use FluentResults' Result.Try for that conversion.
public static class ResultExtension
- Inheritance
-
ResultExtension
- Inherited Members
Examples
Task<Result<Order>> GetOrderAsync(int id) => ...;
var globalResult = Result.Ok();
var result = await GetOrderAsync(42)
.OnSuccessNotNull(order => Console.WriteLine($"Order {order.Id} found"))
.OnSuccessNull(() => Console.WriteLine("No such order"))
.OnFailed(globalResult)
.LogIfFailed();
Methods
Compensate(Result, Func<IReadOnlyCollection<IError>, IResultBase>)
Runs a clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Result Compensate(this Result result, Func<IReadOnlyCollection<IError>, IResultBase> compensation)
Parameters
resultResultThe result to inspect.
compensationFunc<IReadOnlyCollection<IError>, IResultBase>The clean-up receiving the errors of the failed result.
Returns
- Result
A new failed result with the reasons of both, or
resultwhen it succeeded.
Remarks
A successful result is returned unchanged and compensation is not called. Otherwise the new result carries the
reasons of result followed by those of the clean-up, so it stays failed whatever the clean-up returns, and an error of the
clean-up is not lost. Use Recover to replace the failure instead. An exception thrown by the clean-up propagates to the caller.
Exceptions
- ArgumentNullException
compensationis null.
Compensate(Task<Result>, Func<IReadOnlyCollection<IError>, IResultBase>)
Awaits the task, then runs a clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Task<Result> Compensate(this Task<Result> result, Func<IReadOnlyCollection<IError>, IResultBase> compensation)
Parameters
resultTask<Result>The task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, IResultBase>The clean-up receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
Compensate(ValueTask<Result>, Func<IReadOnlyCollection<IError>, IResultBase>)
Awaits the value task, then runs a clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static ValueTask<Result> Compensate(this ValueTask<Result> result, Func<IReadOnlyCollection<IError>, IResultBase> compensation)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, IResultBase>The clean-up receiving the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
CompensateAsync<TResult>(Result, Func<IReadOnlyCollection<IError>, Task<TResult>>)
Awaits an asynchronous clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Task<Result> CompensateAsync<TResult>(this Result result, Func<IReadOnlyCollection<IError>, Task<TResult>> compensation) where TResult : IResultBase
Parameters
resultResultThe result to inspect.
compensationFunc<IReadOnlyCollection<IError>, Task<TResult>>The clean-up receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with a new failed result with the reasons of both, or with
resultwhen it succeeded.
Type Parameters
TResultThe type of the result produced by the clean-up.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
CompensateAsync<TResult>(Task<Result>, Func<IReadOnlyCollection<IError>, Task<TResult>>)
Awaits the task, then awaits an asynchronous clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Task<Result> CompensateAsync<TResult>(this Task<Result> result, Func<IReadOnlyCollection<IError>, Task<TResult>> compensation) where TResult : IResultBase
Parameters
resultTask<Result>The task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, Task<TResult>>The clean-up receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Type Parameters
TResultThe type of the result produced by the clean-up.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
CompensateAsync<TResult>(ValueTask<Result>, Func<IReadOnlyCollection<IError>, Task<TResult>>)
Awaits the value task, then awaits an asynchronous clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static ValueTask<Result> CompensateAsync<TResult>(this ValueTask<Result> result, Func<IReadOnlyCollection<IError>, Task<TResult>> compensation) where TResult : IResultBase
Parameters
resultValueTask<Result>The value task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, Task<TResult>>The clean-up receiving the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Type Parameters
TResultThe type of the result produced by the clean-up.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
CompensateAsync<TValue, TResult>(Result<TValue>, Func<IReadOnlyCollection<IError>, Task<TResult>>)
Awaits an asynchronous clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Task<Result<TValue>> CompensateAsync<TValue, TResult>(this Result<TValue> result, Func<IReadOnlyCollection<IError>, Task<TResult>> compensation) where TResult : IResultBase
Parameters
resultResult<TValue>The result to inspect.
compensationFunc<IReadOnlyCollection<IError>, Task<TResult>>The clean-up receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with a new failed result with the reasons of both, or with
resultwhen it succeeded.
Type Parameters
TValueThe type of the value carried by the result.
TResultThe type of the result produced by the clean-up.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
CompensateAsync<TValue, TResult>(Task<Result<TValue>>, Func<IReadOnlyCollection<IError>, Task<TResult>>)
Awaits the task, then awaits an asynchronous clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Task<Result<TValue>> CompensateAsync<TValue, TResult>(this Task<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Task<TResult>> compensation) where TResult : IResultBase
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, Task<TResult>>The clean-up receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Type Parameters
TValueThe type of the value carried by the result.
TResultThe type of the result produced by the clean-up.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
CompensateAsync<TValue, TResult>(ValueTask<Result<TValue>>, Func<IReadOnlyCollection<IError>, Task<TResult>>)
Awaits the value task, then awaits an asynchronous clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static ValueTask<Result<TValue>> CompensateAsync<TValue, TResult>(this ValueTask<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Task<TResult>> compensation) where TResult : IResultBase
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, Task<TResult>>The clean-up receiving the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Type Parameters
TValueThe type of the value carried by the result.
TResultThe type of the result produced by the clean-up.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
Compensate<TValue>(Result<TValue>, Func<IReadOnlyCollection<IError>, IResultBase>)
Runs a clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Result<TValue> Compensate<TValue>(this Result<TValue> result, Func<IReadOnlyCollection<IError>, IResultBase> compensation)
Parameters
resultResult<TValue>The result to inspect.
compensationFunc<IReadOnlyCollection<IError>, IResultBase>The clean-up receiving the errors of the failed result.
Returns
- Result<TValue>
A new failed result with the reasons of both, or
resultwhen it succeeded.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
Compensate<TValue>(Task<Result<TValue>>, Func<IReadOnlyCollection<IError>, IResultBase>)
Awaits the task, then runs a clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static Task<Result<TValue>> Compensate<TValue>(this Task<Result<TValue>> result, Func<IReadOnlyCollection<IError>, IResultBase> compensation)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, IResultBase>The clean-up receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
Compensate<TValue>(ValueTask<Result<TValue>>, Func<IReadOnlyCollection<IError>, IResultBase>)
Awaits the value task, then runs a clean-up that can fail when the result is failed, and adds its reasons to the failure.
public static ValueTask<Result<TValue>> Compensate<TValue>(this ValueTask<Result<TValue>> result, Func<IReadOnlyCollection<IError>, IResultBase> compensation)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
compensationFunc<IReadOnlyCollection<IError>, IResultBase>The clean-up receiving the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with a new failed result with the reasons of both, or with the awaited result when it succeeded.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
compensationis null.
EnsureAsync<TValue, TResult>(Result<TValue>, Func<TValue, Task<TResult>>)
Awaits an asynchronous step that can fail on the value of a successful result, and keeps the value when the step succeeds.
public static Task<Result<TValue>> EnsureAsync<TValue, TResult>(this Result<TValue> result, Func<TValue, Task<TResult>> step) where TResult : IResultBase
Parameters
resultResult<TValue>The result to inspect.
stepFunc<TValue, Task<TResult>>The step receiving the value.
Returns
- Task<Result<TValue>>
A task completing with a new result with the value and the reasons of both, or with
resultwhen it failed.
Type Parameters
TValueThe type of the value carried by the result.
TResultThe type of the result produced by the step.
Remarks
Exceptions
- ArgumentNullException
stepis null.
EnsureAsync<TValue, TResult>(Task<Result<TValue>>, Func<TValue, Task<TResult>>)
Awaits the task, then awaits an asynchronous step that can fail on the value of a successful result, and keeps the value when the step succeeds.
public static Task<Result<TValue>> EnsureAsync<TValue, TResult>(this Task<Result<TValue>> result, Func<TValue, Task<TResult>> step) where TResult : IResultBase
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
stepFunc<TValue, Task<TResult>>The step receiving the value.
Returns
- Task<Result<TValue>>
A task completing with a new result with the value and the reasons of both, or with the awaited result when it failed.
Type Parameters
TValueThe type of the value carried by the result.
TResultThe type of the result produced by the step.
Remarks
Exceptions
- ArgumentNullException
stepis null.
EnsureAsync<TValue, TResult>(ValueTask<Result<TValue>>, Func<TValue, Task<TResult>>)
Awaits the value task, then awaits an asynchronous step that can fail on the value of a successful result, and keeps the value when the step succeeds.
public static ValueTask<Result<TValue>> EnsureAsync<TValue, TResult>(this ValueTask<Result<TValue>> result, Func<TValue, Task<TResult>> step) where TResult : IResultBase
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
stepFunc<TValue, Task<TResult>>The step receiving the value.
Returns
- ValueTask<Result<TValue>>
A value task completing with a new result with the value and the reasons of both, or with the awaited result when it failed.
Type Parameters
TValueThe type of the value carried by the result.
TResultThe type of the result produced by the step.
Remarks
Exceptions
- ArgumentNullException
stepis null.
EnsureNotNull<TValue>(Result<TValue?>, Func<IError>)
Turns a successful result whose value is null into a failed result carrying the error built by error.
public static Result<TValue> EnsureNotNull<TValue>(this Result<TValue?> result, Func<IError> error)
Parameters
resultResult<TValue>The result to inspect.
errorFunc<IError>Builds the error when the value is null; it is only called in that case.
Returns
- Result<TValue>
A new result with the value of
result, or failed.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
A failed result keeps its errors and error is not called. A successful result with a value keeps it, now typed as not
null. The reasons of the original result are always kept. A nullable value type is returned as is, still typed as nullable.
Exceptions
- ArgumentNullException
erroris null.
EnsureNotNull<TValue>(Task<Result<TValue?>>, Func<IError>)
Awaits the task, then turns a successful result whose value is null into a failed result carrying the error built by error.
public static Task<Result<TValue>> EnsureNotNull<TValue>(this Task<Result<TValue?>> result, Func<IError> error)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
errorFunc<IError>Builds the error when the value is null; it is only called in that case.
Returns
- Task<Result<TValue>>
A task completing with a new result with the value of the awaited result, or failed.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
erroris null.
EnsureNotNull<TValue>(ValueTask<Result<TValue?>>, Func<IError>)
Awaits the value task, then turns a successful result whose value is null into a failed result carrying the error built by error.
public static ValueTask<Result<TValue>> EnsureNotNull<TValue>(this ValueTask<Result<TValue?>> result, Func<IError> error)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
errorFunc<IError>Builds the error when the value is null; it is only called in that case.
Returns
- ValueTask<Result<TValue>>
A value task completing with a new result with the value of the awaited result, or failed.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
erroris null.
Ensure<TValue>(Result<TValue>, Func<TValue, IResultBase>)
Runs a step that can fail on the value of a successful result, and keeps the value when the step succeeds.
public static Result<TValue> Ensure<TValue>(this Result<TValue> result, Func<TValue, IResultBase> step)
Parameters
resultResult<TValue>The result to inspect.
stepFunc<TValue, IResultBase>The step receiving the value.
Returns
- Result<TValue>
A new result with the value of
resultand the reasons of both, orresultwhen it failed.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
A failed result is returned unchanged and step is not called. Otherwise the new result carries the reasons of
result followed by those of the step: it fails with the errors of the step, or succeeds with the original value. The value
of a result returned by the step is ignored; use Then to continue with it. An exception thrown by the step propagates to the caller.
Exceptions
- ArgumentNullException
stepis null.
Ensure<TValue>(Task<Result<TValue>>, Func<TValue, IResultBase>)
Awaits the task, then runs a step that can fail on the value of a successful result, and keeps the value when the step succeeds.
public static Task<Result<TValue>> Ensure<TValue>(this Task<Result<TValue>> result, Func<TValue, IResultBase> step)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
stepFunc<TValue, IResultBase>The step receiving the value.
Returns
- Task<Result<TValue>>
A task completing with a new result with the value and the reasons of both, or with the awaited result when it failed.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
stepis null.
Ensure<TValue>(ValueTask<Result<TValue>>, Func<TValue, IResultBase>)
Awaits the value task, then runs a step that can fail on the value of a successful result, and keeps the value when the step succeeds.
public static ValueTask<Result<TValue>> Ensure<TValue>(this ValueTask<Result<TValue>> result, Func<TValue, IResultBase> step)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
stepFunc<TValue, IResultBase>The step receiving the value.
Returns
- ValueTask<Result<TValue>>
A value task completing with a new result with the value and the reasons of both, or with the awaited result when it failed.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
stepis null.
LogIfFailed(Task<Result>, LogLevel)
Awaits the task, then passes the result and logLevel to the FluentResults logger when the result is failed.
public static Task<Result> LogIfFailed(this Task<Result> result, LogLevel logLevel = LogLevel.Error)
Parameters
resultTask<Result>The task producing the result to inspect.
logLevelLogLevelThe level handed to the result logger. Defaults to Error.
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Remarks
It calls the instance method LogIfFailed(LogLevel) of the FluentResults result, which hands the failed result and the level to the IResultLogger configured with Result.Setup (see AddResultLogger); nothing is logged when none is configured. Arc4u's FluentLogger logs each error at logLevel, except a ValidationError (logged at the level of its severity) and an exceptional error (logged as an exception). The original result is returned unchanged.
LogIfFailed(ValueTask<Result>, LogLevel)
Awaits the value task, then passes the result and logLevel to the FluentResults logger when the result is failed.
public static ValueTask<Result> LogIfFailed(this ValueTask<Result> result, LogLevel logLevel = LogLevel.Error)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
logLevelLogLevelThe level handed to the result logger. Defaults to Error.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Remarks
It calls the instance method LogIfFailed(LogLevel) of the FluentResults result, which hands the failed result and the level to the IResultLogger configured with Result.Setup (see AddResultLogger); nothing is logged when none is configured. Arc4u's FluentLogger logs each error at logLevel, except a ValidationError (logged at the level of its severity) and an exceptional error (logged as an exception). The original result is returned unchanged.
LogIfFailed<TValue>(Task<Result<TValue>>, LogLevel)
Awaits the task, then passes the result and logLevel to the FluentResults logger when the result is failed.
public static Task<Result<TValue>> LogIfFailed<TValue>(this Task<Result<TValue>> result, LogLevel logLevel = LogLevel.Error)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
logLevelLogLevelThe level handed to the result logger. Defaults to Error.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
It calls the instance method LogIfFailed(LogLevel) of the FluentResults result, which hands the failed result and the level to the IResultLogger configured with Result.Setup (see AddResultLogger); nothing is logged when none is configured. Arc4u's FluentLogger logs each error at logLevel, except a ValidationError (logged at the level of its severity) and an exceptional error (logged as an exception). The original result is returned unchanged.
LogIfFailed<TValue>(ValueTask<Result<TValue>>, LogLevel)
Awaits the value task, then passes the result and logLevel to the FluentResults logger when the result is failed.
public static ValueTask<Result<TValue>> LogIfFailed<TValue>(this ValueTask<Result<TValue>> result, LogLevel logLevel = LogLevel.Error)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
logLevelLogLevelThe level handed to the result logger. Defaults to Error.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
It calls the instance method LogIfFailed(LogLevel) of the FluentResults result, which hands the failed result and the level to the IResultLogger configured with Result.Setup (see AddResultLogger); nothing is logged when none is configured. Arc4u's FluentLogger logs each error at logLevel, except a ValidationError (logged at the level of its severity) and an exceptional error (logged as an exception). The original result is returned unchanged.
MatchAsync<TOut>(Result, Func<Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the callback matching the state of the result and returns what it produces.
public static Task<TOut> MatchAsync<TOut>(this Result result, Func<Task<TOut>> onSuccess, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultResultThe result to match.
onSuccessFunc<Task<TOut>>Produces the outcome of a successful result.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
MatchAsync<TOut>(Task<Result>, Func<Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the task, then awaits the callback matching the state of the result and returns what it produces.
public static Task<TOut> MatchAsync<TOut>(this Task<Result> result, Func<Task<TOut>> onSuccess, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultTask<Result>The task producing the result to match.
onSuccessFunc<Task<TOut>>Produces the outcome of a successful result.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
MatchAsync<TOut>(ValueTask<Result>, Func<Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the value task, then awaits the callback matching the state of the result and returns what it produces.
public static ValueTask<TOut> MatchAsync<TOut>(this ValueTask<Result> result, Func<Task<TOut>> onSuccess, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultValueTask<Result>The value task producing the result to match.
onSuccessFunc<Task<TOut>>Produces the outcome of a successful result.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- ValueTask<TOut>
A value task completing with the value produced by the callback that was called.
Type Parameters
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
MatchAsync<TValue, TOut>(Result<TValue>, Func<TValue, Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the callback matching the state of the result and returns what it produces.
public static Task<TOut> MatchAsync<TValue, TOut>(this Result<TValue> result, Func<TValue, Task<TOut>> onSuccess, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultResult<TValue>The result to match.
onSuccessFunc<TValue, Task<TOut>>Produces the outcome of a successful result from its value, which can be null.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
See Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
MatchAsync<TValue, TOut>(Result<TValue?>, Func<TValue, Task<TOut>>, Func<Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the callback matching the state of the result, telling a successful result with a value from one whose value is null, and returns what it produces.
public static Task<TOut> MatchAsync<TValue, TOut>(this Result<TValue?> result, Func<TValue, Task<TOut>> onSuccessNotNull, Func<Task<TOut>> onSuccessNull, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultResult<TValue>The result to match.
onSuccessNotNullFunc<TValue, Task<TOut>>Produces the outcome of a successful result from its value, which is not null.
onSuccessNullFunc<Task<TOut>>Produces the outcome of a successful result whose value is null.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
One of
onSuccessNotNull,onSuccessNull,onFailedis null.
MatchAsync<TValue, TOut>(Task<Result<TValue>>, Func<TValue, Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the task, then awaits the callback matching the state of the result and returns what it produces.
public static Task<TOut> MatchAsync<TValue, TOut>(this Task<Result<TValue>> result, Func<TValue, Task<TOut>> onSuccess, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultTask<Result<TValue>>The task producing the result to match.
onSuccessFunc<TValue, Task<TOut>>Produces the outcome of a successful result from its value, which can be null.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
See Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
MatchAsync<TValue, TOut>(Task<Result<TValue?>>, Func<TValue, Task<TOut>>, Func<Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the task, then awaits the callback matching the state of the result, telling a successful result with a value from one whose value is null, and returns what it produces.
public static Task<TOut> MatchAsync<TValue, TOut>(this Task<Result<TValue?>> result, Func<TValue, Task<TOut>> onSuccessNotNull, Func<Task<TOut>> onSuccessNull, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultTask<Result<TValue>>The task producing the result to match.
onSuccessNotNullFunc<TValue, Task<TOut>>Produces the outcome of a successful result from its value, which is not null.
onSuccessNullFunc<Task<TOut>>Produces the outcome of a successful result whose value is null.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
One of
onSuccessNotNull,onSuccessNull,onFailedis null.
MatchAsync<TValue, TOut>(ValueTask<Result<TValue>>, Func<TValue, Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the value task, then awaits the callback matching the state of the result and returns what it produces.
public static ValueTask<TOut> MatchAsync<TValue, TOut>(this ValueTask<Result<TValue>> result, Func<TValue, Task<TOut>> onSuccess, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to match.
onSuccessFunc<TValue, Task<TOut>>Produces the outcome of a successful result from its value, which can be null.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- ValueTask<TOut>
A value task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
See Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
MatchAsync<TValue, TOut>(ValueTask<Result<TValue?>>, Func<TValue, Task<TOut>>, Func<Task<TOut>>, Func<IReadOnlyCollection<IError>, Task<TOut>>)
Awaits the value task, then awaits the callback matching the state of the result, telling a successful result with a value from one whose value is null, and returns what it produces.
public static ValueTask<TOut> MatchAsync<TValue, TOut>(this ValueTask<Result<TValue?>> result, Func<TValue, Task<TOut>> onSuccessNotNull, Func<Task<TOut>> onSuccessNull, Func<IReadOnlyCollection<IError>, Task<TOut>> onFailed)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to match.
onSuccessNotNullFunc<TValue, Task<TOut>>Produces the outcome of a successful result from its value, which is not null.
onSuccessNullFunc<Task<TOut>>Produces the outcome of a successful result whose value is null.
onFailedFunc<IReadOnlyCollection<IError>, Task<TOut>>Produces the outcome of a failed result from its errors.
Returns
- ValueTask<TOut>
A value task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
One of
onSuccessNotNull,onSuccessNull,onFailedis null.
Match<TOut>(Result, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Calls the callback matching the state of the result and returns what it produces.
public static TOut Match<TOut>(this Result result, Func<TOut> onSuccess, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultResultThe result to match.
onSuccessFunc<TOut>Produces the outcome of a successful result.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- TOut
The value produced by the callback that was called.
Type Parameters
TOutThe type produced by the callbacks.
Remarks
Ends a chain by turning the result into another type, for instance an HTTP response or a message for the user. Exactly one
callback is called. Unlike OnSuccess and OnFailed, the callbacks produce the value returned by the method, so no variable needs
to be assigned from a callback. An exception thrown by a callback propagates to the caller.
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
Match<TOut>(Task<Result>, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Awaits the task, then calls the callback matching the state of the result and returns what it produces.
public static Task<TOut> Match<TOut>(this Task<Result> result, Func<TOut> onSuccess, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultTask<Result>The task producing the result to match.
onSuccessFunc<TOut>Produces the outcome of a successful result.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
Match<TOut>(ValueTask<Result>, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Awaits the value task, then calls the callback matching the state of the result and returns what it produces.
public static ValueTask<TOut> Match<TOut>(this ValueTask<Result> result, Func<TOut> onSuccess, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultValueTask<Result>The value task producing the result to match.
onSuccessFunc<TOut>Produces the outcome of a successful result.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- ValueTask<TOut>
A value task completing with the value produced by the callback that was called.
Type Parameters
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Calls the callback matching the state of the result and returns what it produces.
public static TOut Match<TValue, TOut>(this Result<TValue> result, Func<TValue, TOut> onSuccess, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultResult<TValue>The result to match.
onSuccessFunc<TValue, TOut>Produces the outcome of a successful result from its value, which can be null.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- TOut
The value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
See Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
Match<TValue, TOut>(Result<TValue?>, Func<TValue, TOut>, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Calls the callback matching the state of the result, telling a successful result with a value from one whose value is null, and returns what it produces.
public static TOut Match<TValue, TOut>(this Result<TValue?> result, Func<TValue, TOut> onSuccessNotNull, Func<TOut> onSuccessNull, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultResult<TValue>The result to match.
onSuccessNotNullFunc<TValue, TOut>Produces the outcome of a successful result from its value, which is not null.
onSuccessNullFunc<TOut>Produces the outcome of a successful result whose value is null.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- TOut
The value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
Meant for a result whose value is declared nullable, such as Result<Order?>: onSuccessNotNull then receives
a value that is not null. For a value declared not nullable, use the overload with a single success callback.
See Match<TOut>(Result, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
One of
onSuccessNotNull,onSuccessNull,onFailedis null.
Match<TValue, TOut>(Task<Result<TValue>>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Awaits the task, then calls the callback matching the state of the result and returns what it produces.
public static Task<TOut> Match<TValue, TOut>(this Task<Result<TValue>> result, Func<TValue, TOut> onSuccess, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultTask<Result<TValue>>The task producing the result to match.
onSuccessFunc<TValue, TOut>Produces the outcome of a successful result from its value, which can be null.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
See Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
Match<TValue, TOut>(Task<Result<TValue?>>, Func<TValue, TOut>, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Awaits the task, then calls the callback matching the state of the result, telling a successful result with a value from one whose value is null, and returns what it produces.
public static Task<TOut> Match<TValue, TOut>(this Task<Result<TValue?>> result, Func<TValue, TOut> onSuccessNotNull, Func<TOut> onSuccessNull, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultTask<Result<TValue>>The task producing the result to match.
onSuccessNotNullFunc<TValue, TOut>Produces the outcome of a successful result from its value, which is not null.
onSuccessNullFunc<TOut>Produces the outcome of a successful result whose value is null.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- Task<TOut>
A task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
One of
onSuccessNotNull,onSuccessNull,onFailedis null.
Match<TValue, TOut>(ValueTask<Result<TValue>>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Awaits the value task, then calls the callback matching the state of the result and returns what it produces.
public static ValueTask<TOut> Match<TValue, TOut>(this ValueTask<Result<TValue>> result, Func<TValue, TOut> onSuccess, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to match.
onSuccessFunc<TValue, TOut>Produces the outcome of a successful result from its value, which can be null.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- ValueTask<TOut>
A value task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
See Match<TValue, TOut>(Result<TValue>, Func<TValue, TOut>, Func<IReadOnlyCollection<IError>, TOut>).
Exceptions
- ArgumentNullException
onSuccessoronFailedis null.
Match<TValue, TOut>(ValueTask<Result<TValue?>>, Func<TValue, TOut>, Func<TOut>, Func<IReadOnlyCollection<IError>, TOut>)
Awaits the value task, then calls the callback matching the state of the result, telling a successful result with a value from one whose value is null, and returns what it produces.
public static ValueTask<TOut> Match<TValue, TOut>(this ValueTask<Result<TValue?>> result, Func<TValue, TOut> onSuccessNotNull, Func<TOut> onSuccessNull, Func<IReadOnlyCollection<IError>, TOut> onFailed)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to match.
onSuccessNotNullFunc<TValue, TOut>Produces the outcome of a successful result from its value, which is not null.
onSuccessNullFunc<TOut>Produces the outcome of a successful result whose value is null.
onFailedFunc<IReadOnlyCollection<IError>, TOut>Produces the outcome of a failed result from its errors.
Returns
- ValueTask<TOut>
A value task completing with the value produced by the callback that was called.
Type Parameters
TValueThe type of the value carried by the result.
TOutThe type produced by the callbacks.
Remarks
Exceptions
- ArgumentNullException
One of
onSuccessNotNull,onSuccessNull,onFailedis null.
OnFailed(Result, Result)
Copies the errors of the result into globalResult when the result is failed.
public static Result OnFailed(this Result result, Result globalResult)
Parameters
resultResultThe result to inspect.
globalResultResultThe result that collects the errors of the failed result.
Returns
- Result
The
resultreceived, unchanged.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed(Result, Action<IReadOnlyCollection<IError>>)
Invokes the callback with the errors of the result when the result is failed.
public static Result OnFailed(this Result result, Action<IReadOnlyCollection<IError>> action)
Parameters
resultResultThe result to inspect.
actionAction<IReadOnlyCollection<IError>>The callback receiving the errors of the failed result.
Returns
- Result
The
resultreceived, unchanged.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnFailed(Task<Result>, Result)
Awaits the task, then copies the errors of the result into globalResult when the result is failed.
public static Task<Result> OnFailed(this Task<Result> result, Result globalResult)
Parameters
resultTask<Result>The task producing the result to inspect.
globalResultResultThe result that collects the errors of the failed result.
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed(Task<Result>, Action<IReadOnlyCollection<IError>>)
Awaits the task, then invokes the callback with the errors of the result when the result is failed.
public static Task<Result> OnFailed(this Task<Result> result, Action<IReadOnlyCollection<IError>> action)
Parameters
resultTask<Result>The task producing the result to inspect.
actionAction<IReadOnlyCollection<IError>>The callback receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnFailed(ValueTask<Result>, Result)
Awaits the value task, then copies the errors of the result into globalResult when the result is failed.
public static ValueTask<Result> OnFailed(this ValueTask<Result> result, Result globalResult)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
globalResultResultThe result that collects the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed(ValueTask<Result>, Action<IReadOnlyCollection<IError>>)
Awaits the value task, then invokes the callback with the errors of the result when the result is failed.
public static ValueTask<Result> OnFailed(this ValueTask<Result> result, Action<IReadOnlyCollection<IError>> action)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
actionAction<IReadOnlyCollection<IError>>The callback receiving the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnFailedAsync(Result, Func<IReadOnlyCollection<IError>, Task>)
Awaits the asynchronous callback with the errors of the result when the result is failed.
public static Task<Result> OnFailedAsync(this Result result, Func<IReadOnlyCollection<IError>, Task> func)
Parameters
resultResultThe result to inspect.
funcFunc<IReadOnlyCollection<IError>, Task>The callback receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with the
resultreceived, unchanged, once the callback has run.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnFailedAsync(Task<Result>, Func<IReadOnlyCollection<IError>, Task>)
Awaits the task, then awaits the asynchronous callback with the errors of the result when the result is failed.
public static Task<Result> OnFailedAsync(this Task<Result> result, Func<IReadOnlyCollection<IError>, Task> func)
Parameters
resultTask<Result>The task producing the result to inspect.
funcFunc<IReadOnlyCollection<IError>, Task>The callback receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnFailedAsync(ValueTask<Result>, Func<IReadOnlyCollection<IError>, Task>)
Awaits the value task, then awaits the asynchronous callback with the errors of the result when the result is failed.
public static ValueTask<Result> OnFailedAsync(this ValueTask<Result> result, Func<IReadOnlyCollection<IError>, Task> func)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
funcFunc<IReadOnlyCollection<IError>, Task>The callback receiving the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnFailedAsync<TValue>(Result<TValue>, Func<IReadOnlyCollection<IError>, Task>)
Awaits the asynchronous callback with the errors of the result when the result is failed.
public static Task<Result<TValue>> OnFailedAsync<TValue>(this Result<TValue> result, Func<IReadOnlyCollection<IError>, Task> func)
Parameters
resultResult<TValue>The result to inspect.
funcFunc<IReadOnlyCollection<IError>, Task>The callback receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the
resultreceived, unchanged, once the callback has run.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnFailedAsync<TValue>(Task<Result<TValue>>, Func<IReadOnlyCollection<IError>, Task>)
Awaits the task, then awaits the asynchronous callback with the errors of the result when the result is failed.
public static Task<Result<TValue>> OnFailedAsync<TValue>(this Task<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Task> func)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
funcFunc<IReadOnlyCollection<IError>, Task>The callback receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnFailedAsync<TValue>(ValueTask<Result<TValue>>, Func<IReadOnlyCollection<IError>, Task>)
Awaits the value task, then awaits the asynchronous callback with the errors of the result when the result is failed.
public static ValueTask<Result<TValue>> OnFailedAsync<TValue>(this ValueTask<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Task> func)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
funcFunc<IReadOnlyCollection<IError>, Task>The callback receiving the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnFailed<TGlobal>(Result, Result<TGlobal>)
Collects the errors of an untyped result into a typed global one, the synchronous twin of OnFailed<TGlobal>(Task<Result>, Result<TGlobal>).
public static Result OnFailed<TGlobal>(this Result result, Result<TGlobal> globalResult)
Parameters
resultResultThe result to inspect.
globalResultResult<TGlobal>The result that collects the errors of the failed result.
Returns
- Result
The
resultreceived, unchanged.
Type Parameters
TGlobalThe type of the value carried by the global result.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue>(Result<TValue>, Result)
Collects the errors of a typed result into an untyped global one, the synchronous twin of OnFailed<TValue>(Task<Result<TValue>>, Result).
public static Result<TValue> OnFailed<TValue>(this Result<TValue> result, Result globalResult)
Parameters
resultResult<TValue>The result to inspect.
globalResultResultThe result that collects the errors of the failed result.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue>(Result<TValue>, Action<IReadOnlyCollection<IError>>)
Invokes the callback with the errors of the result when the result is failed.
public static Result<TValue> OnFailed<TValue>(this Result<TValue> result, Action<IReadOnlyCollection<IError>> action)
Parameters
resultResult<TValue>The result to inspect.
actionAction<IReadOnlyCollection<IError>>The callback receiving the errors of the failed result.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnFailed<TValue>(Task<Result<TValue>>, Result)
Awaits the task, then copies the errors of the result into globalResult when the result is failed.
public static Task<Result<TValue>> OnFailed<TValue>(this Task<Result<TValue>> result, Result globalResult)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
globalResultResultThe result that collects the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue>(Task<Result<TValue>>, Action<IReadOnlyCollection<IError>>)
Awaits the task, then invokes the callback with the errors of the result when the result is failed.
public static Task<Result<TValue>> OnFailed<TValue>(this Task<Result<TValue>> result, Action<IReadOnlyCollection<IError>> action)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
actionAction<IReadOnlyCollection<IError>>The callback receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnFailed<TGlobal>(Task<Result>, Result<TGlobal>)
Awaits the task, then copies the errors of the result into globalResult when the result is failed.
public static Task<Result> OnFailed<TGlobal>(this Task<Result> result, Result<TGlobal> globalResult)
Parameters
resultTask<Result>The task producing the result to inspect.
globalResultResult<TGlobal>The result that collects the errors of the failed result.
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Type Parameters
TGlobalThe type of the value carried by the global result.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue>(ValueTask<Result<TValue>>, Result)
Awaits the value task, then copies the errors of the result into globalResult when the result is failed.
public static ValueTask<Result<TValue>> OnFailed<TValue>(this ValueTask<Result<TValue>> result, Result globalResult)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
globalResultResultThe result that collects the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue>(ValueTask<Result<TValue>>, Action<IReadOnlyCollection<IError>>)
Awaits the value task, then invokes the callback with the errors of the result when the result is failed.
public static ValueTask<Result<TValue>> OnFailed<TValue>(this ValueTask<Result<TValue>> result, Action<IReadOnlyCollection<IError>> action)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
actionAction<IReadOnlyCollection<IError>>The callback receiving the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped when the result is successful. The original result is always returned unchanged. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnFailed<TGlobal>(ValueTask<Result>, Result<TGlobal>)
Collects the errors of an untyped result into a typed global one, the ValueTask twin of OnFailed<TGlobal>(Task<Result>, Result<TGlobal>).
public static ValueTask<Result> OnFailed<TGlobal>(this ValueTask<Result> result, Result<TGlobal> globalResult)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
globalResultResult<TGlobal>The result that collects the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Type Parameters
TGlobalThe type of the value carried by the global result.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue, TGlobal>(Result<TValue>, Result<TGlobal>)
Copies the errors of the result into globalResult when the result is failed.
public static Result<TValue> OnFailed<TValue, TGlobal>(this Result<TValue> result, Result<TGlobal> globalResult)
Parameters
resultResult<TValue>The result to inspect.
globalResultResult<TGlobal>The result that collects the errors of the failed result.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
TGlobalThe type of the value carried by the global result.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue, TGlobal>(Task<Result<TValue>>, Result<TGlobal>)
Awaits the task, then copies the errors of the result into globalResult when the result is failed.
public static Task<Result<TValue>> OnFailed<TValue, TGlobal>(this Task<Result<TValue>> result, Result<TGlobal> globalResult)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
globalResultResult<TGlobal>The result that collects the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
TGlobalThe type of the value carried by the global result.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnFailed<TValue, TGlobal>(ValueTask<Result<TValue>>, Result<TGlobal>)
Awaits the value task, then copies the errors of the result into globalResult when the result is failed.
public static ValueTask<Result<TValue>> OnFailed<TValue, TGlobal>(this ValueTask<Result<TValue>> result, Result<TGlobal> globalResult)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
globalResultResult<TGlobal>The result that collects the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
TGlobalThe type of the value carried by the global result.
Remarks
Use it to aggregate the errors of several steps into a single result. The original result is returned unchanged.
Exceptions
- ArgumentNullException
globalResultis null.
OnSuccess(Result, Action)
Invokes the callback only when the result is successful.
public static Result OnSuccess(this Result result, Action action)
Parameters
resultResultThe result to inspect.
actionActionThe callback to run.
Returns
- Result
The
resultreceived, unchanged.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess(Task<Result>, Action)
Awaits the task, then invokes the callback only when the result is successful.
public static Task<Result> OnSuccess(this Task<Result> result, Action action)
Parameters
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess(ValueTask<Result>, Action)
Awaits the value task, then invokes the callback only when the result is successful.
public static ValueTask<Result> OnSuccess(this ValueTask<Result> result, Action action)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
actionActionThe callback to run.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessAsync(Result, Func<Task>)
Awaits the asynchronous callback only when the result is successful.
public static Task<Result> OnSuccessAsync(this Result result, Func<Task> func)
Parameters
Returns
- Task<Result>
A task completing with the
resultreceived, unchanged, once the callback has run.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync(Task<Result>, Func<Task>)
Awaits the task, then awaits the asynchronous callback only when the result is successful.
public static Task<Result> OnSuccessAsync(this Task<Result> result, Func<Task> func)
Parameters
Returns
- Task<Result>
A task completing with the awaited result, unchanged.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync(ValueTask<Result>, Func<Task>)
Awaits the value task, then awaits the asynchronous callback only when the result is successful.
public static ValueTask<Result> OnSuccessAsync(this ValueTask<Result> result, Func<Task> func)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- ValueTask<Result>
A value task completing with the awaited result, unchanged.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync<TValue>(Result<TValue>, Func<Task>)
Awaits the asynchronous callback only when the result is successful.
public static Task<Result<TValue>> OnSuccessAsync<TValue>(this Result<TValue> result, Func<Task> func)
Parameters
Returns
- Task<Result<TValue>>
A task completing with the
resultreceived, unchanged, once the callback has run.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync<TValue>(Result<TValue>, Func<TValue, Task>)
Awaits the asynchronous callback, passing it the value of the result only when the result is successful.
public static Task<Result<TValue>> OnSuccessAsync<TValue>(this Result<TValue> result, Func<TValue, Task> func)
Parameters
resultResult<TValue>The result to inspect.
funcFunc<TValue, Task>The callback receiving the value of the result.
Returns
- Task<Result<TValue>>
A task completing with the
resultreceived, unchanged, once the callback has run.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync<TValue>(Task<Result<TValue>>, Func<Task>)
Awaits the task, then awaits the asynchronous callback only when the result is successful.
public static Task<Result<TValue>> OnSuccessAsync<TValue>(this Task<Result<TValue>> result, Func<Task> func)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync<TValue>(Task<Result<TValue>>, Func<TValue, Task>)
Awaits the task, then awaits the asynchronous callback, passing it the value of the result only when the result is successful.
public static Task<Result<TValue>> OnSuccessAsync<TValue>(this Task<Result<TValue>> result, Func<TValue, Task> func)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
funcFunc<TValue, Task>The callback receiving the value of the result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync<TValue>(ValueTask<Result<TValue>>, Func<Task>)
Awaits the value task, then awaits the asynchronous callback only when the result is successful.
public static ValueTask<Result<TValue>> OnSuccessAsync<TValue>(this ValueTask<Result<TValue>> result, Func<Task> func)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessAsync<TValue>(ValueTask<Result<TValue>>, Func<TValue, Task>)
Awaits the value task, then awaits the asynchronous callback, passing it the value of the result only when the result is successful.
public static ValueTask<Result<TValue>> OnSuccessAsync<TValue>(this ValueTask<Result<TValue>> result, Func<TValue, Task> func)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
funcFunc<TValue, Task>The callback receiving the value of the result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNullAsync<TValue>(Result<TValue>, Func<Task>)
Awaits the asynchronous callback only when the result is successful and its value is not null.
public static Task<Result<TValue>> OnSuccessNotNullAsync<TValue>(this Result<TValue> result, Func<Task> func)
Parameters
Returns
- Task<Result<TValue>>
A task completing with the
resultreceived, unchanged, once the callback has run.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNullAsync<TValue>(Result<TValue>, Func<TValue, Task>)
Awaits the asynchronous callback, passing it the value of the result only when the result is successful and its value is not null.
public static Task<Result<TValue>> OnSuccessNotNullAsync<TValue>(this Result<TValue> result, Func<TValue, Task> func)
Parameters
resultResult<TValue>The result to inspect.
funcFunc<TValue, Task>The callback receiving the value of the result.
Returns
- Task<Result<TValue>>
A task completing with the
resultreceived, unchanged, once the callback has run.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNullAsync<TValue>(Task<Result<TValue>>, Func<Task>)
Awaits the task, then awaits the asynchronous callback only when the result is successful and its value is not null.
public static Task<Result<TValue>> OnSuccessNotNullAsync<TValue>(this Task<Result<TValue>> result, Func<Task> func)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNullAsync<TValue>(Task<Result<TValue>>, Func<TValue, Task>)
Awaits the task, then awaits the asynchronous callback, passing it the value of the result only when the result is successful and its value is not null.
public static Task<Result<TValue>> OnSuccessNotNullAsync<TValue>(this Task<Result<TValue>> result, Func<TValue, Task> func)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
funcFunc<TValue, Task>The callback receiving the value of the result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNullAsync<TValue>(ValueTask<Result<TValue>>, Func<Task>)
Awaits the value task, then awaits the asynchronous callback only when the result is successful and its value is not null.
public static ValueTask<Result<TValue>> OnSuccessNotNullAsync<TValue>(this ValueTask<Result<TValue>> result, Func<Task> func)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNullAsync<TValue>(ValueTask<Result<TValue>>, Func<TValue, Task>)
Awaits the value task, then awaits the asynchronous callback, passing it the value of the result only when the result is successful and its value is not null.
public static ValueTask<Result<TValue>> OnSuccessNotNullAsync<TValue>(this ValueTask<Result<TValue>> result, Func<TValue, Task> func)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
funcFunc<TValue, Task>The callback receiving the value of the result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNotNull<TValue>(Result<TValue>, Action)
Invokes the callback only when the result is successful and its value is not null.
public static Result<TValue> OnSuccessNotNull<TValue>(this Result<TValue> result, Action action)
Parameters
resultResult<TValue>The result to inspect.
actionActionThe callback to run.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNotNull<TValue>(Result<TValue>, Action<TValue>)
Invokes the callback with the value of the result only when the result is successful and its value is not null.
public static Result<TValue> OnSuccessNotNull<TValue>(this Result<TValue> result, Action<TValue> action)
Parameters
resultResult<TValue>The result to inspect.
actionAction<TValue>The callback receiving the value of the result.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNotNull<TValue>(Task<Result<TValue>>, Action)
Awaits the task, then invokes the callback only when the result is successful and its value is not null.
public static Task<Result<TValue>> OnSuccessNotNull<TValue>(this Task<Result<TValue>> result, Action action)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
actionActionThe callback to run.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNotNull<TValue>(Task<Result<TValue>>, Action<TValue>)
Awaits the task, then invokes the callback with the value of the result only when the result is successful and its value is not null.
public static Task<Result<TValue>> OnSuccessNotNull<TValue>(this Task<Result<TValue>> result, Action<TValue> action)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
actionAction<TValue>The callback receiving the value of the result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNotNull<TValue>(ValueTask<Result<TValue>>, Action)
Awaits the value task, then invokes the callback only when the result is successful and its value is not null.
public static ValueTask<Result<TValue>> OnSuccessNotNull<TValue>(this ValueTask<Result<TValue>> result, Action action)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
actionActionThe callback to run.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNotNull<TValue>(ValueTask<Result<TValue>>, Action<TValue>)
Awaits the value task, then invokes the callback with the value of the result only when the result is successful and its value is not null.
public static ValueTask<Result<TValue>> OnSuccessNotNull<TValue>(this ValueTask<Result<TValue>> result, Action<TValue> action)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
actionAction<TValue>The callback receiving the value of the result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNullAsync<TValue>(Result<TValue>, Func<Task>)
Awaits the asynchronous callback only when the result is successful and its value is null.
public static Task<Result<TValue>> OnSuccessNullAsync<TValue>(this Result<TValue> result, Func<Task> func)
Parameters
Returns
- Task<Result<TValue>>
A task completing with the
resultreceived, unchanged, once the callback has run.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNullAsync<TValue>(Task<Result<TValue>>, Func<Task>)
Awaits the task, then awaits the asynchronous callback only when the result is successful and its value is null.
public static Task<Result<TValue>> OnSuccessNullAsync<TValue>(this Task<Result<TValue>> result, Func<Task> func)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNullAsync<TValue>(ValueTask<Result<TValue>>, Func<Task>)
Awaits the value task, then awaits the asynchronous callback only when the result is successful and its value is null.
public static ValueTask<Result<TValue>> OnSuccessNullAsync<TValue>(this ValueTask<Result<TValue>> result, Func<Task> func)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
funcFunc<Task>The callback to run.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
funcis null.
OnSuccessNull<TValue>(Result<TValue>, Action)
Invokes the callback only when the result is successful and its value is null.
public static Result<TValue> OnSuccessNull<TValue>(this Result<TValue> result, Action action)
Parameters
resultResult<TValue>The result to inspect.
actionActionThe callback to run.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNull<TValue>(Task<Result<TValue>>, Action)
Awaits the task, then invokes the callback only when the result is successful and its value is null.
public static Task<Result<TValue>> OnSuccessNull<TValue>(this Task<Result<TValue>> result, Action action)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
actionActionThe callback to run.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccessNull<TValue>(ValueTask<Result<TValue>>, Action)
Awaits the value task, then invokes the callback only when the result is successful and its value is null.
public static ValueTask<Result<TValue>> OnSuccessNull<TValue>(this ValueTask<Result<TValue>> result, Action action)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
actionActionThe callback to run.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess<TValue>(Result<TValue>, Action)
Invokes the callback only when the result is successful.
public static Result<TValue> OnSuccess<TValue>(this Result<TValue> result, Action action)
Parameters
resultResult<TValue>The result to inspect.
actionActionThe callback to run.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess<TValue>(Result<TValue>, Action<TValue>)
Invokes the callback with the value of the result only when the result is successful.
public static Result<TValue> OnSuccess<TValue>(this Result<TValue> result, Action<TValue> action)
Parameters
resultResult<TValue>The result to inspect.
actionAction<TValue>The callback receiving the value of the result.
Returns
- Result<TValue>
The
resultreceived, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
A successful Result may still carry a null value: use OnSuccessNotNull<TValue>(Result<TValue>, Action<TValue>) when the callback needs a value it can dereference.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess<TValue>(Task<Result<TValue>>, Action)
Awaits the task, then invokes the callback only when the result is successful.
public static Task<Result<TValue>> OnSuccess<TValue>(this Task<Result<TValue>> result, Action action)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
actionActionThe callback to run.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess<TValue>(Task<Result<TValue>>, Action<TValue>)
Awaits the task, then invokes the callback with the value of the result only when the result is successful.
public static Task<Result<TValue>> OnSuccess<TValue>(this Task<Result<TValue>> result, Action<TValue> action)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
actionAction<TValue>The callback receiving the value of the result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess<TValue>(ValueTask<Result<TValue>>, Action)
Awaits the value task, then invokes the callback only when the result is successful.
public static ValueTask<Result<TValue>> OnSuccess<TValue>(this ValueTask<Result<TValue>> result, Action action)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
actionActionThe callback to run.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
OnSuccess<TValue>(ValueTask<Result<TValue>>, Action<TValue>)
Awaits the value task, then invokes the callback with the value of the result only when the result is successful.
public static ValueTask<Result<TValue>> OnSuccess<TValue>(this ValueTask<Result<TValue>> result, Action<TValue> action)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
actionAction<TValue>The callback receiving the value of the result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result, unchanged.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
The callback is skipped otherwise. The original result is always returned unchanged, so calls can be chained. An exception thrown by the callback propagates to the caller.
Exceptions
- ArgumentNullException
actionis null.
Recover(Result, Func<IReadOnlyCollection<IError>, Result>)
Replaces a failed result with the result of a fallback.
public static Result Recover(this Result result, Func<IReadOnlyCollection<IError>, Result> recovery)
Parameters
resultResultThe result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Result>The fallback receiving the errors of the failed result.
Returns
- Result
resultwhen it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Remarks
A successful result is returned unchanged and recovery is not called. When the fallback succeeds, its result is
returned and the original errors are dropped: the failure has been handled. When the fallback fails too, the new result carries the reasons of
result followed by those of the fallback, so neither failure is lost. An exception thrown by the fallback propagates to the caller.
Exceptions
- ArgumentNullException
recoveryis null.
Recover(Task<Result>, Func<IReadOnlyCollection<IError>, Result>)
Awaits the task, then replaces a failed result with the result of a fallback.
public static Task<Result> Recover(this Task<Result> result, Func<IReadOnlyCollection<IError>, Result> recovery)
Parameters
resultTask<Result>The task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Result>The fallback receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
Recover(ValueTask<Result>, Func<IReadOnlyCollection<IError>, Result>)
Awaits the value task, then replaces a failed result with the result of a fallback.
public static ValueTask<Result> Recover(this ValueTask<Result> result, Func<IReadOnlyCollection<IError>, Result> recovery)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Result>The fallback receiving the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
RecoverAsync(Result, Func<IReadOnlyCollection<IError>, Task<Result>>)
Awaits an asynchronous fallback replacing a failed result.
public static Task<Result> RecoverAsync(this Result result, Func<IReadOnlyCollection<IError>, Task<Result>> recovery)
Parameters
resultResultThe result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Task<Result>>The fallback receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with
resultwhen it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
RecoverAsync(Task<Result>, Func<IReadOnlyCollection<IError>, Task<Result>>)
Awaits the task, then awaits an asynchronous fallback replacing a failed result.
public static Task<Result> RecoverAsync(this Task<Result> result, Func<IReadOnlyCollection<IError>, Task<Result>> recovery)
Parameters
resultTask<Result>The task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Task<Result>>The fallback receiving the errors of the failed result.
Returns
- Task<Result>
A task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
RecoverAsync(ValueTask<Result>, Func<IReadOnlyCollection<IError>, Task<Result>>)
Awaits the value task, then awaits an asynchronous fallback replacing a failed result.
public static ValueTask<Result> RecoverAsync(this ValueTask<Result> result, Func<IReadOnlyCollection<IError>, Task<Result>> recovery)
Parameters
resultValueTask<Result>The value task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Task<Result>>The fallback receiving the errors of the failed result.
Returns
- ValueTask<Result>
A value task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
RecoverAsync<TValue>(Result<TValue>, Func<IReadOnlyCollection<IError>, Task<Result<TValue>>>)
Awaits an asynchronous fallback replacing a failed result.
public static Task<Result<TValue>> RecoverAsync<TValue>(this Result<TValue> result, Func<IReadOnlyCollection<IError>, Task<Result<TValue>>> recovery)
Parameters
resultResult<TValue>The result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Task<Result<TValue>>>The fallback receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with
resultwhen it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
RecoverAsync<TValue>(Task<Result<TValue>>, Func<IReadOnlyCollection<IError>, Task<Result<TValue>>>)
Awaits the task, then awaits an asynchronous fallback replacing a failed result.
public static Task<Result<TValue>> RecoverAsync<TValue>(this Task<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Task<Result<TValue>>> recovery)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Task<Result<TValue>>>The fallback receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
RecoverAsync<TValue>(ValueTask<Result<TValue>>, Func<IReadOnlyCollection<IError>, Task<Result<TValue>>>)
Awaits the value task, then awaits an asynchronous fallback replacing a failed result.
public static ValueTask<Result<TValue>> RecoverAsync<TValue>(this ValueTask<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Task<Result<TValue>>> recovery)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Task<Result<TValue>>>The fallback receiving the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
Recover<TValue>(Result<TValue>, Func<IReadOnlyCollection<IError>, Result<TValue>>)
Replaces a failed result with the result of a fallback.
public static Result<TValue> Recover<TValue>(this Result<TValue> result, Func<IReadOnlyCollection<IError>, Result<TValue>> recovery)
Parameters
resultResult<TValue>The result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Result<TValue>>The fallback receiving the errors of the failed result.
Returns
- Result<TValue>
resultwhen it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
Recover<TValue>(Task<Result<TValue>>, Func<IReadOnlyCollection<IError>, Result<TValue>>)
Awaits the task, then replaces a failed result with the result of a fallback.
public static Task<Result<TValue>> Recover<TValue>(this Task<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Result<TValue>> recovery)
Parameters
resultTask<Result<TValue>>The task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Result<TValue>>The fallback receiving the errors of the failed result.
Returns
- Task<Result<TValue>>
A task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
Recover<TValue>(ValueTask<Result<TValue>>, Func<IReadOnlyCollection<IError>, Result<TValue>>)
Awaits the value task, then replaces a failed result with the result of a fallback.
public static ValueTask<Result<TValue>> Recover<TValue>(this ValueTask<Result<TValue>> result, Func<IReadOnlyCollection<IError>, Result<TValue>> recovery)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to inspect.
recoveryFunc<IReadOnlyCollection<IError>, Result<TValue>>The fallback receiving the errors of the failed result.
Returns
- ValueTask<Result<TValue>>
A value task completing with the awaited result when it succeeded, the result of the fallback when it succeeded, or a new failed result with the reasons of both.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
recoveryis null.
Then(Result, Func<Result>)
Runs the next step only when the result is successful, and continues with the result of that step.
public static Result Then(this Result result, Func<Result> next)
Parameters
resultResultThe result to continue from.
nextFunc<Result>The step.
Returns
- Result
A new result with the reasons of both and the value of the step, or with the errors of the original result.
Remarks
It is FluentResults' Bind under a name of the Arc4u chain, for every receiver. A failed result skips the step and its errors
are carried on. Otherwise the new result carries the reasons of the original result followed by those of the step, and the value of the step.
An exception thrown by the step propagates to the caller.
Exceptions
- ArgumentNullException
nextis null.
Then(Task<Result>, Func<Result>)
Awaits the task, then runs the next step only when the result is successful, and continues with the result of that step.
public static Task<Result> Then(this Task<Result> result, Func<Result> next)
Parameters
Returns
- Task<Result>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then(ValueTask<Result>, Func<Result>)
Awaits the value task, then runs the next step only when the result is successful, and continues with the result of that step.
public static ValueTask<Result> Then(this ValueTask<Result> result, Func<Result> next)
Parameters
resultValueTask<Result>The value task producing the result to continue from.
nextFunc<Result>The step.
Returns
- ValueTask<Result>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync(Result, Func<Task<Result>>)
Awaits the next step only when the result is successful, and continues with the result of that step.
public static Task<Result> ThenAsync(this Result result, Func<Task<Result>> next)
Parameters
Returns
- Task<Result>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync(Task<Result>, Func<Task<Result>>)
Awaits the task, then awaits the next step only when the result is successful, and continues with the result of that step.
public static Task<Result> ThenAsync(this Task<Result> result, Func<Task<Result>> next)
Parameters
resultTask<Result>The task producing the result to continue from.
nextFunc<Task<Result>>The step.
Returns
- Task<Result>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync(ValueTask<Result>, Func<Task<Result>>)
Awaits the value task, then awaits the next step only when the result is successful, and continues with the result of that step.
public static ValueTask<Result> ThenAsync(this ValueTask<Result> result, Func<Task<Result>> next)
Parameters
resultValueTask<Result>The value task producing the result to continue from.
nextFunc<Task<Result>>The step.
Returns
- ValueTask<Result>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TNewValue>(Result, Func<Task<Result<TNewValue>>>)
Awaits the next step only when the result is successful, and continues with the result of that step.
public static Task<Result<TNewValue>> ThenAsync<TNewValue>(this Result result, Func<Task<Result<TNewValue>>> next)
Parameters
Returns
- Task<Result<TNewValue>>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TValue>(Result<TValue>, Func<TValue, Task<Result>>)
Awaits the next step with its value only when the result is successful, and continues with the result of that step.
public static Task<Result> ThenAsync<TValue>(this Result<TValue> result, Func<TValue, Task<Result>> next)
Parameters
resultResult<TValue>The result to continue from.
nextFunc<TValue, Task<Result>>The step receiving the value.
Returns
- Task<Result>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TValue>(Task<Result<TValue>>, Func<TValue, Task<Result>>)
Awaits the task, then awaits the next step with its value only when the result is successful, and continues with the result of that step.
public static Task<Result> ThenAsync<TValue>(this Task<Result<TValue>> result, Func<TValue, Task<Result>> next)
Parameters
resultTask<Result<TValue>>The task producing the result to continue from.
nextFunc<TValue, Task<Result>>The step receiving the value.
Returns
- Task<Result>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TNewValue>(Task<Result>, Func<Task<Result<TNewValue>>>)
Awaits the task, then awaits the next step only when the result is successful, and continues with the result of that step.
public static Task<Result<TNewValue>> ThenAsync<TNewValue>(this Task<Result> result, Func<Task<Result<TNewValue>>> next)
Parameters
resultTask<Result>The task producing the result to continue from.
nextFunc<Task<Result<TNewValue>>>The step.
Returns
- Task<Result<TNewValue>>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TValue>(ValueTask<Result<TValue>>, Func<TValue, Task<Result>>)
Awaits the value task, then awaits the next step with its value only when the result is successful, and continues with the result of that step.
public static ValueTask<Result> ThenAsync<TValue>(this ValueTask<Result<TValue>> result, Func<TValue, Task<Result>> next)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to continue from.
nextFunc<TValue, Task<Result>>The step receiving the value.
Returns
- ValueTask<Result>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TNewValue>(ValueTask<Result>, Func<Task<Result<TNewValue>>>)
Awaits the value task, then awaits the next step only when the result is successful, and continues with the result of that step.
public static ValueTask<Result<TNewValue>> ThenAsync<TNewValue>(this ValueTask<Result> result, Func<Task<Result<TNewValue>>> next)
Parameters
resultValueTask<Result>The value task producing the result to continue from.
nextFunc<Task<Result<TNewValue>>>The step.
Returns
- ValueTask<Result<TNewValue>>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TValue, TNewValue>(Result<TValue>, Func<TValue, Task<Result<TNewValue>>>)
Awaits the next step with its value only when the result is successful, and continues with the result of that step.
public static Task<Result<TNewValue>> ThenAsync<TValue, TNewValue>(this Result<TValue> result, Func<TValue, Task<Result<TNewValue>>> next)
Parameters
resultResult<TValue>The result to continue from.
nextFunc<TValue, Task<Result<TNewValue>>>The step receiving the value.
Returns
- Task<Result<TNewValue>>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TValue, TNewValue>(Task<Result<TValue>>, Func<TValue, Task<Result<TNewValue>>>)
Awaits the task, then awaits the next step with its value only when the result is successful, and continues with the result of that step.
public static Task<Result<TNewValue>> ThenAsync<TValue, TNewValue>(this Task<Result<TValue>> result, Func<TValue, Task<Result<TNewValue>>> next)
Parameters
resultTask<Result<TValue>>The task producing the result to continue from.
nextFunc<TValue, Task<Result<TNewValue>>>The step receiving the value.
Returns
- Task<Result<TNewValue>>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
ThenAsync<TValue, TNewValue>(ValueTask<Result<TValue>>, Func<TValue, Task<Result<TNewValue>>>)
Awaits the value task, then awaits the next step with its value only when the result is successful, and continues with the result of that step.
public static ValueTask<Result<TNewValue>> ThenAsync<TValue, TNewValue>(this ValueTask<Result<TValue>> result, Func<TValue, Task<Result<TNewValue>>> next)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to continue from.
nextFunc<TValue, Task<Result<TNewValue>>>The step receiving the value.
Returns
- ValueTask<Result<TNewValue>>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TNewValue>(Result, Func<Result<TNewValue>>)
Runs the next step only when the result is successful, and continues with the result of that step.
public static Result<TNewValue> Then<TNewValue>(this Result result, Func<Result<TNewValue>> next)
Parameters
resultResultThe result to continue from.
nextFunc<Result<TNewValue>>The step.
Returns
- Result<TNewValue>
A new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TValue>(Result<TValue>, Func<TValue, Result>)
Runs the next step with its value only when the result is successful, and continues with the result of that step.
public static Result Then<TValue>(this Result<TValue> result, Func<TValue, Result> next)
Parameters
resultResult<TValue>The result to continue from.
nextFunc<TValue, Result>The step receiving the value.
Returns
- Result
A new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TValue>(Task<Result<TValue>>, Func<TValue, Result>)
Awaits the task, then runs the next step with its value only when the result is successful, and continues with the result of that step.
public static Task<Result> Then<TValue>(this Task<Result<TValue>> result, Func<TValue, Result> next)
Parameters
resultTask<Result<TValue>>The task producing the result to continue from.
nextFunc<TValue, Result>The step receiving the value.
Returns
- Task<Result>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TNewValue>(Task<Result>, Func<Result<TNewValue>>)
Awaits the task, then runs the next step only when the result is successful, and continues with the result of that step.
public static Task<Result<TNewValue>> Then<TNewValue>(this Task<Result> result, Func<Result<TNewValue>> next)
Parameters
resultTask<Result>The task producing the result to continue from.
nextFunc<Result<TNewValue>>The step.
Returns
- Task<Result<TNewValue>>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TValue>(ValueTask<Result<TValue>>, Func<TValue, Result>)
Awaits the value task, then runs the next step with its value only when the result is successful, and continues with the result of that step.
public static ValueTask<Result> Then<TValue>(this ValueTask<Result<TValue>> result, Func<TValue, Result> next)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to continue from.
nextFunc<TValue, Result>The step receiving the value.
Returns
- ValueTask<Result>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TNewValue>(ValueTask<Result>, Func<Result<TNewValue>>)
Awaits the value task, then runs the next step only when the result is successful, and continues with the result of that step.
public static ValueTask<Result<TNewValue>> Then<TNewValue>(this ValueTask<Result> result, Func<Result<TNewValue>> next)
Parameters
resultValueTask<Result>The value task producing the result to continue from.
nextFunc<Result<TNewValue>>The step.
Returns
- ValueTask<Result<TNewValue>>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TValue, TNewValue>(Result<TValue>, Func<TValue, Result<TNewValue>>)
Runs the next step with its value only when the result is successful, and continues with the result of that step.
public static Result<TNewValue> Then<TValue, TNewValue>(this Result<TValue> result, Func<TValue, Result<TNewValue>> next)
Parameters
resultResult<TValue>The result to continue from.
nextFunc<TValue, Result<TNewValue>>The step receiving the value.
Returns
- Result<TNewValue>
A new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TValue, TNewValue>(Task<Result<TValue>>, Func<TValue, Result<TNewValue>>)
Awaits the task, then runs the next step with its value only when the result is successful, and continues with the result of that step.
public static Task<Result<TNewValue>> Then<TValue, TNewValue>(this Task<Result<TValue>> result, Func<TValue, Result<TNewValue>> next)
Parameters
resultTask<Result<TValue>>The task producing the result to continue from.
nextFunc<TValue, Result<TNewValue>>The step receiving the value.
Returns
- Task<Result<TNewValue>>
A task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.
Then<TValue, TNewValue>(ValueTask<Result<TValue>>, Func<TValue, Result<TNewValue>>)
Awaits the value task, then runs the next step with its value only when the result is successful, and continues with the result of that step.
public static ValueTask<Result<TNewValue>> Then<TValue, TNewValue>(this ValueTask<Result<TValue>> result, Func<TValue, Result<TNewValue>> next)
Parameters
resultValueTask<Result<TValue>>The value task producing the result to continue from.
nextFunc<TValue, Result<TNewValue>>The step receiving the value.
Returns
- ValueTask<Result<TNewValue>>
A value task completing with a new result with the reasons of both and the value of the step, or with the errors of the original result.
Type Parameters
TValueThe type of the value carried by the result.
TNewValueThe type of the value produced by the step.
Remarks
Exceptions
- ArgumentNullException
nextis null.