I'm writing gRPC services using ASP.NET Core using GRPC.ASPNETCore.
I've tried to add an Exception Filter for gRPC methods like this
services.AddMvc(options =>
{
options.Filters.Add(typeof(BaseExceptionFilter));
});
or using the UseExceptionHandler
extension method like this
app.UseExceptionHandler(configure =>
{
configure.Run(async e =>
{
Console.WriteLine("Exception test code");
});
});
But both of them are not working (not intercepting code).
Is it possible to add global exception handler for gRPC services in ASP.NET Core?
I don't want to write try-catch
code wrapper for each method I want to call.