Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Latest commit

 

History

History
35 lines (26 loc) · 962 Bytes

README.md

File metadata and controls

35 lines (26 loc) · 962 Bytes

Deprecated

This repository is no longer maintained.

ng-http-error-interceptor

Trigger events on any response error for Angular.

Manual

This interceptor broadcasts two events upon error responses:

  • http-error - triggered regardless of HTTP response status code.
    $rootScope.$on('http-error', function(response) {
      // Executes on every HTTP response error.
    });
  • http-error-XXX - triggered only if HTTP response status code matches XXX (404, 500, etc).
    $rootScope.$on('http-error-403', function(response) {
      // Executes on every HTTP response that errors due to a 403 status code.
    });

To bypass interceptor, set httpErrorInterceptor flag to false.

    $http.get('/spam', { httpErrorInterceptor: false });

Examples

See specs for usage example.