OrphanedHandlerException Class
Definition
- Assemblies
- Savvyio.Core.dll
The exception that is thrown when an IHandler<TRequest> implementation cannot be resolved.
public class OrphanedHandlerException : ArgumentException, ISerializable
- Inheritance
-
OrphanedHandlerException
- Implements
- Inherited Members
Examples
Throw an OrphanedHandlerException when a dispatcher receives a request type with no registered handler. Use OrphanedHandlerException.Create<TRequest, THandler> to produce the exception with a formatted message.
using System;
using Savvyio;
using Savvyio.Dispatchers;
using Savvyio.Handlers;
namespace ExampleApp;
public sealed class DispatcherWithValidation
{
public void ValidateHandlerPresence<THandler>(IRequest request)
where THandler : IHandler<IRequest>
{
try
{
throw OrphanedHandlerException.Create<IRequest, THandler>(request, "request");
}
catch (OrphanedHandlerException exception)
{
Console.WriteLine($"No handler found: {exception.Message}");
}
}
}
public sealed record PlaceOrderRequest(string OrderId) : Request;
Constructors
| Name | Description |
|---|---|
| OrphanedHandlerException(string, string) | Initializes a new instance of the OrphanedHandlerException class. |
Methods
| Name | Description |
|---|---|
| Create<TRequest, THandler>(TRequest, string) | Creates a new instance of OrphanedHandlerException using the provided generic type arguments. |