Class ResultMapErrorExtensions
Extension methods for transforming errors in the failure path of Result types.
public static class ResultMapErrorExtensions
- Inheritance
-
ResultMapErrorExtensions
- Inherited Members
Methods
MapError(Result, Func<ImmutableList<IError>, ImmutableList<IError>>)
Transforms the errors of a failed result using the provided mapper. If the result is successful, it is returned unchanged. The result state (IsSuccess/IsFailure) never changes.
public static Result MapError(this Result result, Func<ImmutableList<IError>, ImmutableList<IError>> mapper)
Parameters
resultResultThe result to map errors on.
mapperFunc<ImmutableList<IError>, ImmutableList<IError>>Function that transforms the current error list.
Returns
- Result
The original result if successful; otherwise a new failed result with mapped errors.
MapErrorAsync(Result, Func<ImmutableList<IError>, Task<ImmutableList<IError>>>, CancellationToken)
Asynchronously transforms the errors of a failed result using the provided async mapper. If the result is successful, it is returned unchanged.
public static Task<Result> MapErrorAsync(this Result result, Func<ImmutableList<IError>, Task<ImmutableList<IError>>> mapper, CancellationToken cancellationToken = default)
Parameters
resultResultThe result to map errors on.
mapperFunc<ImmutableList<IError>, Task<ImmutableList<IError>>>Async function that transforms the current error list.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
MapErrorAsync<T>(Result<T>, Func<ImmutableList<IError>, Task<ImmutableList<IError>>>, CancellationToken)
Asynchronously transforms the errors of a failed result using the provided async mapper. If the result is successful, it is returned unchanged.
public static Task<Result<T>> MapErrorAsync<T>(this Result<T> result, Func<ImmutableList<IError>, Task<ImmutableList<IError>>> mapper, CancellationToken cancellationToken = default)
Parameters
resultResult<T>The result to map errors on.
mapperFunc<ImmutableList<IError>, Task<ImmutableList<IError>>>Async function that transforms the current error list.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- Task<Result<T>>
The original result if successful; otherwise a new failed result with mapped errors.
Type Parameters
TThe value type.
MapError<T>(Result<T>, Func<ImmutableList<IError>, ImmutableList<IError>>)
Transforms the errors of a failed result using the provided mapper. If the result is successful, it is returned unchanged. The result state (IsSuccess/IsFailure) never changes.
public static Result<T> MapError<T>(this Result<T> result, Func<ImmutableList<IError>, ImmutableList<IError>> mapper)
Parameters
resultResult<T>The result to map errors on.
mapperFunc<ImmutableList<IError>, ImmutableList<IError>>Function that transforms the current error list.
Returns
- Result<T>
The original result if successful; otherwise a new failed result with mapped errors.
Type Parameters
TThe value type.