title: AngularJS catch all status-codes for $http actions?
body: <p>My <code>$http</code> functions can return the following errors:</p>
  <blockquote>
  <p>POST <a href="http://foobar.dev/foobar" rel="nofollow noreferrer">http://foobar.dev/foobar</a> 500 (Internal Server Error)</p>
  <p>POST <a href="http://foobar.dev/foobar" rel="nofollow noreferrer">http://foobar.dev/foobar</a> 401 (Unauthorized)</p>
  </blockquote>
  <p>Isn't there a way I can catch all status codes?</p>
  <pre><code>$http.post('/foobar', form)
      .success(function(data, status, headers, config) {
          console.info(data);
      })
      .error(function(data, status, headers, config) {
          console.error(data);
          if(status === 401) {
              $scope.setTemplate('show-login');
          }
          if(status === 500) {
              $scope.setTemplate('server-error');
          }
      }
  );  
  </code></pre>
  <p>Where <code>$scope.setTemplate()</code> is a function inside the Controller that sets a view.</p>
  <p>But then I have to do this for each <code>error()</code> function and there are a lot functions like this which also not making it DRY code :P</p>
  <p>What I want is to catch the error and do an action based on the status code returned in the error.</p>
  <p>FYI: I'm not using Angulars <code>$routeProvider()</code>.</p>