Class ResultTErrorTapExtensions
- Namespace
- REslava.Result.Extensions
- Assembly
- REslava.Result.dll
Tap and TapOnFailure overloads for Result<TValue, TError> typed pipelines.
Execute side effects without altering the result — the original result is always returned.
public static class ResultTErrorTapExtensions
- Inheritance
-
ResultTErrorTapExtensions
- Inherited Members
Methods
TapOnFailure<TValue, TError>(Result<TValue, TError>, Action<TError>)
Executes a side effect on the error value and returns the original result unchanged. The action is not called if the result is a success.
public static Result<TValue, TError> TapOnFailure<TValue, TError>(this Result<TValue, TError> result, Action<TError> action) where TError : IError
Parameters
resultResult<TValue, TError>The result to tap into.
actionAction<TError>The side effect to run on failure.
Returns
- Result<TValue, TError>
The original result, unchanged.
Type Parameters
TValueThe value type.
TErrorThe error type. Must implement IError.
Examples
Validate(req)
.TapOnFailure(err => logger.LogWarning("Validation failed: {Msg}", err.Message))
.Bind(ReserveInventory);
Tap<TValue, TError>(Result<TValue, TError>, Action<TValue>)
Executes a side effect on the success value and returns the original result unchanged. The action is not called if the result is a failure.
public static Result<TValue, TError> Tap<TValue, TError>(this Result<TValue, TError> result, Action<TValue> action) where TError : IError
Parameters
resultResult<TValue, TError>The result to tap into.
actionAction<TValue>The side effect to run on success.
Returns
- Result<TValue, TError>
The original result, unchanged.
Type Parameters
TValueThe value type.
TErrorThe error type. Must implement IError.
Examples
Validate(req)
.Tap(order => logger.LogInformation("Order {Id} validated", order.Id))
.Bind(ReserveInventory);