I'm Working on the .Net Core 2.2 Web API Project. I have handled thrown exceptions by creating Middleware by referring this post
Startup.cs
app.UseMiddleware(typeof(ExceptionHandleMiddleware));
I'm catching exceptions thrown from catch like below,
try{
.....
}catch(Exception)
{
throw;
}
It is working fine for requests coming through Web API Calls.
Then I Created Another Layer for SignalR, Also Added Middleware to its Startup.cs But it is not catching the exceptions thrown in this layer.
So, I guess middleware is working only for Request-Response Pipeline. SignalR is creating Persistent Connection with Client by choosing protocol on its own. So it is not catching it.
So, Is there a way to catch exceptions in Middleware Or Suggest any other better way to handle it.
Thanks in Advance.