dispatcher inner exception
This commit is contained in:
@@ -5,7 +5,7 @@ namespace AipsCore.Application.Common.Dispatcher;
|
|||||||
|
|
||||||
public class DispatchException : Exception
|
public class DispatchException : Exception
|
||||||
{
|
{
|
||||||
public DispatchException(object commandQuery)
|
public DispatchException(object commandQuery, Exception innerException)
|
||||||
: base($"Error while dispatching '{commandQuery.GetType().Name}'")
|
: base($"Error dispatching '{commandQuery.GetType().Name}' because of: {innerException.Message}", innerException)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
@@ -59,11 +59,15 @@ public sealed class Dispatcher : IDispatcher
|
|||||||
|
|
||||||
private dynamic ResolveHandler(Type handlerType, object commandOrQuery)
|
private dynamic ResolveHandler(Type handlerType, object commandOrQuery)
|
||||||
{
|
{
|
||||||
dynamic? handler = _serviceProvider.GetService(handlerType);
|
dynamic handler;
|
||||||
|
|
||||||
if (handler is null)
|
try
|
||||||
{
|
{
|
||||||
throw new DispatchException(commandOrQuery);
|
handler = _serviceProvider.GetRequiredService(handlerType);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException serviceProviderException)
|
||||||
|
{
|
||||||
|
throw new DispatchException(commandOrQuery, serviceProviderException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
|
|||||||
Reference in New Issue
Block a user