title: Angularjs 1.4 interceptor not working
body: <p>Let me start by saying I'm a noob at angular, so I suspect a very dumb mistake based on my lack of understanding.</p>
  
  <p>I'm trying to create an interceptor to handle request and response errors.</p>
  
  <p>If I put an alert at the top of the file, it's called, so the file it's getting loaded. But none of the other alerts including at the bottom of the file and before the config are getting called. The responseError and requestError never get called...</p>
  
  <p>I've tried simplifying it down to the minimum that reproduces the issue, I've tried several different examples on how to implement it in case i was using outdated code, I tried commenting out the error clause in the controller in case it's swallowing the exception..... I've googled most of the day trying to get this to work, and I'm stumped.</p>
  
  <pre><code>$provide.factory('myHttpInterceptor', function ($q, dependency1, dependency2) {
      return {
          'responseError': function (rejection) {
              alert("Something went wrong");
              return $q.reject(rejection);
          },
          'requestError': function (rejection) {
          alert("Something went wrong");
          return $q.reject(rejection);
      }
      };
  });
  alert('myHttpInterceptor done');
  module.config(['$httpProvider', function ($httpProvider) {
      alert('myHttpInterceptor push');
      $httpProvider.interceptors.push('myHttpInterceptor');
  }]);
  </code></pre>
  
  <p>any help especially toward a solid understanding of what is going on is greatly appreciated </p>
  
  <p>---- answer related info for posterity----</p>
  
  <p>Based the combination on sbedulins and Angad answers I was able to get it 
  working.</p>
  
  <p>First off, once I got it working it worked both with and without single quotes around responeError and RequestError... </p>
  
  <p>dependency1 and 2 were undefined and a cut and paste error from a simplified example i got here on SO. So I removed them.</p>
  
  <p>Then I replaced module with angular.module('defaultApp'), so module is a placeholder in the examples, not some kind of convenient global storing it... you need explicitly define your module, (or the variable module)
  (yes I really am that new to angular)</p>
  
  <p>so once all of those changes were applied to sbedulins examples, i got working code here for both approaches, for postetity here is my actyual working code from my app</p>
  
  <pre><code>angular.module('defaultApp').config(['$provide', '$httpProvider', function ($provide, $httpProvider) {
  
      $provide.factory('myHttpInterceptor', function ($q) {
          return {
              responseError: function (rejection) {
                  alert("Something went wrong");
                  return $q.reject(rejection);
              },
              requestError: function (rejection) {
                  alert("Something went wrong");
                  return $q.reject(rejection);
              }
          };
      });
  
      $httpProvider.interceptors.push('myHttpInterceptor');
  
  }]);
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>angular.module('defaultApp').config(['$httpProvider', function ($httpProvider) {
  
      $httpProvider.interceptors.push(function ( $q ) {
          return {
              'responseError': function (rejection) {
                  alert("Something went wrong");
                  return $q.reject(rejection);
              },
              'requestError': function (rejection) {
                  alert("Something went wrong");
                  return $q.reject(rejection);
              }
          };
      });
  
  }]);
  </code></pre>
  
  <p>Thanks a ton for all of your help, I learned important things about angular shorthand in examples. sbedulin gets the answer, even though I need help from comments to get his/her answer to work</p>