Created
May 22, 2014 09:03
-
-
Save mukgupta/4fa38055a2d7eee982ef to your computer and use it in GitHub Desktop.
AngularJs log HTTP Errors using Sentry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.factory('RavenHTTPInterceptor', ['Raven', '$q', function(Raven, $q) { | |
var httpIgnoreErrors = [401]; //Error codes to be ignored | |
var ignoreError = function(error){ | |
return httpIgnoreErrors.indexOf(error) !== -1; | |
} | |
return { | |
// optional method | |
'requestError': function(rejection) { | |
// do something on error | |
if(!ignoreError(rejection.status)){ | |
Raven.captureException(rejection, {tags: { key: "HTTP Request Error" }}); | |
} | |
return $q.reject(rejection); | |
}, | |
// optional method | |
'responseError': function(rejection) { | |
// do something on error | |
if(!ignoreError(rejection.status)){ | |
Raven.captureException(rejection, {tags: { key: "HTTP Response Error" }}); | |
} | |
return $q.reject(rejection); | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment