Mahmoud Moravej
Mahmoud Moravej

Reputation: 9044

Handle SignalR constructor exceptions

Is there anyway to handle exceptions which are thrown in Hub constructor methods? Currently there is only HubPipelineModule which can handles only calling methods related exceptions but not constructor exception.

Assume in Hub constructor I get the "Database connection error". Now I want to show the end user a proper message.

I checked the following links but they are not helpful in this case :

Upvotes: 0

Views: 220

Answers (1)

halter73
halter73

Reputation: 15234

Your best bet for handling exceptions thrown from a Hub constructor is probably by providing your own IHubActivator.

Here is an example of how you can replace SignalR's IHubActivator. In that example the purpose for replacing IHubActivator was to use Simple Injector to activate hubs, but the same principle applies if you just want to handle/log any exceptions thrown during Hub construction.

Upvotes: 1

Related Questions