I am trying to determine how to get SignalR to properly raise the fail
method of a jQuery deferred.
Currently I am achieving this as follows"
public void JoinChat(string username)
{
var user = userRepo.getUser(username);
if(user == null)
{
throw new Exception('user doesn't exist');
}
//set up user here
}
then in my js for the client I am doing this
$.connection.myHub.joinChat(this.username)
.done(//success callback)
.fail(//fail callback);
I feel that having the Hub generating an exception to achieve the failure on the deferred is not an ideal way to do this, but I haven't been able to find anyway to get a proper fail call back generated.
I would like to avoid having a return code
since there are methods where I am returning actual useful information from the hub (the join method is just a simple example).
Is there a preferred method of invoking the fail condition for the jQuery deferred?