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
callbackICallback<R>The callback to invoke.
requestIUsecaseRequestThe use case request associated with the exception.
exExceptionThe exception that occurred.
Type Parameters
RThe 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