title: AngularJS $resource Error Handing with Callback
body: <p>I have a factory that has multiple services for querying a custom API I built. The callbacks all work, but I'm wondering how I can have any error handling while fetching. </p>
  
  <pre><code>.factory('customApiService', function ($resource) {
        return {
            yelp: function (businessId, callback) {
                var api = $resource('../../api/Yelp/:businessId', {
                    businessId: businessId
                }, {
                    fetch: 'JSONP',
                    'query': { isArray: false }
                });
  
                api.fetch(function (response) {
                    callback(response);
                });
            },
            tripAdvisor: function (hotelId, callback) {
                var api = $resource('../../api/TripAdvisor/:hotelId', {
                    hotelId: hotelId
                }, {
                    fetch: 'JSONP',
                    'query': { isArray: false }
                });
  
                api.fetch(function (response) {
                    callback(response);
                });
            }
        }
    });
  </code></pre>
  
  <p>And an example of using this factory in a controller:</p>
  
  <pre><code>.controller('yelpCtrl', [
    '$scope', 'customApiService', function ($scope, customApiService) {
  
        customApiService.yelp("yelpIdHere", function (d) {
            //On successful callback run code
        });
  
        customApiService.tripAdvisor("tripAdvisorIdHere", function (d) {
            //On successful callback run code
        });
     }
  ])
  </code></pre>
  
  <p>Currently if there is any bad response (404, 500, 504, etc), the callback is not fired.</p>