title: How to handle SignalR server exception at client?
body: <p>The error handler is added like this at client:</p>
  
  <pre><code>$.connection.hub.url = "/signalr";
  $.connection.hub.logging = true;
  $.connection.hub.error(function(error) {
      console.log('SignalrAdapter: ' + error);
  });
  
  $.connection.hub.start().done(function() { me.onStartDone(); });
  // ...
  </code></pre>
  
  <p>At server it is: </p>
  
  <pre><code>hubConfiguration.EnableDetailedErrors = true;
  </code></pre>
  
  <p>Accordingly to <a href="http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#handleerrors" rel="noreferrer">the docs</a> this should be enough.</p>
  
  <p>At my exception throwing it just displays a log text for it and does not invoke the handler:</p>
  
  <pre><code>[18:18:19 GMT+0000()] SignalR: ... [[[my error description here]]] ... 
  </code></pre>
  
  <p>At my cshtml page:</p>
  
  <pre><code>&lt;script src="~/Scripts/vendor/jquery.signalR-2.1.2.js"&gt;&lt;/script&gt;
  &lt;script src="~/signalr/hubs"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>However if I attach an error handler to the method itself it is got called:</p>
  
  <pre><code>$.connection.operatorHub.server.myMethodName(someParam).fail(function(error) {
      console.log("Error handler called: " + error);
  });
  </code></pre>
  
  <p>How to handle a general error? </p>
  
  <p>UPDATE.
  The answer is below. Also see these:</p>
  
  <ul>
  <li><a href="http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-server#handleErrors" rel="noreferrer">http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-server#handleErrors</a></li>
  <li><a href="https://stackoverflow.com/questions/21796087/signalr-owin-and-exception-handling">SignalR, Owin and exception handling</a></li>
  </ul>
  
  <p>Hope it helps someone.</p>