Book Image

SignalR Real-time Application Cookbook

By : Roberto Vespa
Book Image

SignalR Real-time Application Cookbook

By: Roberto Vespa

Overview of this book

Table of Contents (18 chapters)
SignalR Real-time Application Cookbook
About the Author
About the Reviewers

Handling errors

In this last recipe of the chapter, we want to achieve a smarter exception-handling strategy, and for that we apply some of the lessons we learned about the extensibility features of SignalR, along with some other features specific of error management.

Getting ready

For this recipe, we'll use a new empty web application, which we'll call Recipe46.

How to do it…

Our code will contain a Hub with a couple of methods raising exceptions, and the following steps will illustrate how to work around them in order to collect and manage information about the errors:

  1. We create a new Hub called FailingHub using the SignalR Hub Class (v2) template. The following is what it should look like:

    using System;
    using Microsoft.AspNet.SignalR;
    using Microsoft.AspNet.SignalR.Hubs;
    namespace Recipe46
        public class FailingHub : Hub
            public void Basic()
                throw new OutOfMemoryException();
            public void Wrapped()