question

TheBuzzSaw-0182 avatar image
0 Votes"
TheBuzzSaw-0182 asked TheBuzzSaw-0182 answered

Is there a way to specify a universal exception handler for SignalR client message handlers?

I am using the C# SignalR client library, and I caused an exception inside one of my message handlers. (Oops!) I noticed that it silently abandons the handler. Is there any way to specify a general exception handler for when a given delegate fails to handle it? Or do I need to wrap each handler individually in a try-catch block?

connection.On("CreateMessage", () => throw new Exception("Oops!"));
dotnet-aspnetcore-realtime
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I caused an exception inside one of my message handlers. Is there any way to specify a general exception handler for when a given delegate fails to handle it? Hi @TheBuzzSaw-0182, can you clarify more about your requirement?

0 Votes 0 ·

I call connection.On(...) a dozen times to map a dozen handlers. Do I have to put a try-catch around the bodies of every single handler? Or is there way to register a global exception handler for any message handler that throws an exception?

0 Votes 0 ·

Do I have to put a try-catch around the bodies of every single handler? Or is there way to register a global exception handler for any message handler that throws an exception? As far as I know, currently it seems not support register a global exception handler on SignalR client side.

0 Votes 0 ·

1 Answer

TheBuzzSaw-0182 avatar image
0 Votes"
TheBuzzSaw-0182 answered

It sounds like the answer is NO.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.