Managing errors across a complex asynchronous workflow
In this last recipe, we'll introduce one last concept to have a full view of the basic features made available by the JavaScript Hubs API: how to react to errors that occur during all the possible SignalR operational steps and states.
For some specific cases, SignalR offers a couple of native ways to deal with errors as follows:
We can supply a
fail()
callback to any JavaScriptpromise
object that SignalR returns. This means that we can either usefail()
on thepromise
object returned when starting a connection to intercept errors during the connection process, or we can usefail()
on thepromise
object returned during the remote invocation of a Hub method. By hooking a callback with thesefail()
methods, we can be notified about the exceptions that occur during either the networking portion of a remote invocation or the server-side execution of a Hub method. We should observe that for errors occurring because of networking issues, SignalR...