Table of Contents

Class CallbackExtensions

Namespace
Cyclotron.Utilities.CleanArchitecture
Assembly
Cyclotron.Utilities.dll

Provides extension methods for ICallback<R> to simplify error handling.

public static class CallbackExtensions
Inheritance
CallbackExtensions
Inherited Members

Methods

OnError<R>(ICallback<R>, IUsecaseRequest, Exception)

Handles exceptions and invokes the appropriate callback method based on the exception type.

public static void OnError<R>(this ICallback<R> callback, IUsecaseRequest request, Exception ex) where R : IUsecaseResponse

Parameters

callback ICallback<R>

The callback to invoke.

request IUsecaseRequest

The use case request associated with the exception.

ex Exception

The exception that occurred.

Type Parameters

R

The type of response that implements IUsecaseResponse.

Remarks

This method distinguishes between:

  • Cancellation due to explicit cancellation token request - invokes OnCanceled
  • Timeout due to OperationCanceledException without explicit cancellation - invokes OnError with TimedOut type
  • All other exceptions - invokes OnError with Unknown error type