title: Error handling in Angularjs for deferred promise
body: <p>I built a factory to return data that uses an HTTP Get through a deferred promise.  It work great when it is the happy path and the url is correct.  But when there is an error I would like to catch it.  It seems that I am but a 500 error still shows in the console.  Is there a way to catch this also? Also, I want to do processing on the reject I'm having trouble figuring out how to do that.  TIA</p>
  
  <pre><code>angular.module("accQueries")
      .factory('leaseFactory', ['$http', '$q', function ($http, $q) {
  
              return {
                  leases: '',
                  makeRequest: function (url) {
                      // Create the deferred object
                      var deferred = $q.defer();
  
                      $http.get(url).then(function (resp) {
                          deferred.resolve(resp.data);
                      })
                      // potentially catch http error here??
                      .catch(function (err) {
                          deferred.reject(err);
                          console.log('rejected  : ' + err );
                          console.dir(err);
                          this.leases = '';
                      });
  
                      return deferred.promise;
                  },
                  // Return a single lease based on lease number
                  getLease: function (pLeaseNum) {
                      this.leases = this.makeRequest("http://someserver/AccruentQA_DB/webresources/restfulservices.latbllease/leaseNumber/" + pLeaseNum);
                      // Return the lease object stored on the service
                      return this.leases;
                  },
                  // Return all leases based on lease name
                  getLeases: function () {
                      this.leases = this.makeRequest("http://someserver/AccruentQA_DB/webresources/restfulservices.latbllease/name/");
  
                      // Return the lease object stored on the service
                      return this.leases;
                  }
              };
  
          }]);
  </code></pre>