Table of Contents

Class TapOnFailureExtensionsAsync

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Provides asynchronous extension methods for executing side effects on failed Results without changing the Result.

public static class TapOnFailureExtensionsAsync
Inheritance
TapOnFailureExtensionsAsync
Inherited Members

Remarks

These methods enable async error handling patterns such as logging to external services, sending notifications, or recording metrics when operations fail.

All operations run on the failure track - they only execute when the Result has failed.

Methods

TapOnFailureAsync<TValue>(Result<TValue>, Func<Error, Task>)

Asynchronously executes the given async action with the error if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static Task<Result<TValue>> TapOnFailureAsync<TValue>(this Result<TValue> result, Func<Error, Task> func)

Parameters

result Result<TValue>

The result to tap.

func Func<Error, Task>

The async action to execute with the error if the result is a failure.

Returns

Task<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Result<TValue>, Func<Error, ValueTask>)

Asynchronously executes the given async action with the error if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static ValueTask<Result<TValue>> TapOnFailureAsync<TValue>(this Result<TValue> result, Func<Error, ValueTask> func)

Parameters

result Result<TValue>

The result to tap.

func Func<Error, ValueTask>

The async action to execute with the error if the result is a failure.

Returns

ValueTask<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Result<TValue>, Func<Task>)

Asynchronously executes the given async action if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static Task<Result<TValue>> TapOnFailureAsync<TValue>(this Result<TValue> result, Func<Task> func)

Parameters

result Result<TValue>

The result to tap.

func Func<Task>

The async action to execute if the result is a failure.

Returns

Task<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Result<TValue>, Func<ValueTask>)

Asynchronously executes the given async action if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static ValueTask<Result<TValue>> TapOnFailureAsync<TValue>(this Result<TValue> result, Func<ValueTask> func)

Parameters

result Result<TValue>

The result to tap.

func Func<ValueTask>

The async action to execute if the result is a failure.

Returns

ValueTask<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Task<Result<TValue>>, Action)

Asynchronously executes the given action if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static Task<Result<TValue>> TapOnFailureAsync<TValue>(this Task<Result<TValue>> resultTask, Action action)

Parameters

resultTask Task<Result<TValue>>

The task containing the result to tap.

action Action

The action to execute if the result is a failure.

Returns

Task<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Task<Result<TValue>>, Action<Error>)

Asynchronously executes the given action with the error if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static Task<Result<TValue>> TapOnFailureAsync<TValue>(this Task<Result<TValue>> resultTask, Action<Error> action)

Parameters

resultTask Task<Result<TValue>>

The task containing the result to tap.

action Action<Error>

The action to execute with the error if the result is a failure.

Returns

Task<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Task<Result<TValue>>, Func<Error, Task>)

Asynchronously executes the given async action with the error if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static Task<Result<TValue>> TapOnFailureAsync<TValue>(this Task<Result<TValue>> resultTask, Func<Error, Task> func)

Parameters

resultTask Task<Result<TValue>>

The task containing the result to tap.

func Func<Error, Task>

The async action to execute with the error if the result is a failure.

Returns

Task<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(Task<Result<TValue>>, Func<Task>)

Asynchronously executes the given async action if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static Task<Result<TValue>> TapOnFailureAsync<TValue>(this Task<Result<TValue>> resultTask, Func<Task> func)

Parameters

resultTask Task<Result<TValue>>

The task containing the result to tap.

func Func<Task>

The async action to execute if the result is a failure.

Returns

Task<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(ValueTask<Result<TValue>>, Action)

Asynchronously executes the given action if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static ValueTask<Result<TValue>> TapOnFailureAsync<TValue>(this ValueTask<Result<TValue>> resultTask, Action action)

Parameters

resultTask ValueTask<Result<TValue>>

The ValueTask containing the result to tap.

action Action

The action to execute if the result is a failure.

Returns

ValueTask<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(ValueTask<Result<TValue>>, Action<Error>)

Asynchronously executes the given action with the error if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static ValueTask<Result<TValue>> TapOnFailureAsync<TValue>(this ValueTask<Result<TValue>> resultTask, Action<Error> action)

Parameters

resultTask ValueTask<Result<TValue>>

The ValueTask containing the result to tap.

action Action<Error>

The action to execute with the error if the result is a failure.

Returns

ValueTask<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(ValueTask<Result<TValue>>, Func<Error, ValueTask>)

Asynchronously executes the given async action with the error if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static ValueTask<Result<TValue>> TapOnFailureAsync<TValue>(this ValueTask<Result<TValue>> resultTask, Func<Error, ValueTask> func)

Parameters

resultTask ValueTask<Result<TValue>>

The ValueTask containing the result to tap.

func Func<Error, ValueTask>

The async action to execute with the error if the result is a failure.

Returns

ValueTask<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.

TapOnFailureAsync<TValue>(ValueTask<Result<TValue>>, Func<ValueTask>)

Asynchronously executes the given async action if the result is a failure. Returns the original result unchanged.

[RailwayTrack(TrackBehavior.Failure)]
public static ValueTask<Result<TValue>> TapOnFailureAsync<TValue>(this ValueTask<Result<TValue>> resultTask, Func<ValueTask> func)

Parameters

resultTask ValueTask<Result<TValue>>

The ValueTask containing the result to tap.

func Func<ValueTask>

The async action to execute if the result is a failure.

Returns

ValueTask<Result<TValue>>

The original result unchanged.

Type Parameters

TValue

Type of the result value.