Repository navigation
Replies: 1 comment
|
Since you're using Wolverine as an in-process mediator through Wolverine has a built-in option for this: services.AddWolverine(options =>
{
options.InvokeTracing = InvokeTracingMode.Full;
});With This is particularly useful when you're using Wolverine instead of MediatR, because you can get consistent logging without adding a If you need additional custom logging or want to attach extra context to the log, then a global handler policy or middleware would make more sense. I'd try the built-in tracing option first before adding another layer of custom middleware. |
Uh oh!
There was an error while loading. Please reload this page.
I use Wolverine as a replacement for Mediatr in an ASP.NET core webapp
I have several commands that return values, and I use InvokeAsync to call the Wolverine handlers.
If there is an unhandled exception thrown by either handler, I want to log that exception.
Here is my Wolverine setup
I tried using a middleware (commented code), I can not achieve what I want
The only way I managed to have the unhandled exception logged is via a Configure() method in the handler
public static void Configure(HandlerChain chain) => chain.LogUnhandledException<MyHandler>();and that LogUnhandledException is an extension method
However, writing that Configure() for every handler is quite verbose.
Isn't there a simpler way to configure this global exception handler ?
Thanks
All reactions