Skip to content

Instantly share code, notes, and snippets.

@mukgupta
Created May 22, 2014 09:03
Show Gist options
  • Save mukgupta/4fa38055a2d7eee982ef to your computer and use it in GitHub Desktop.
Save mukgupta/4fa38055a2d7eee982ef to your computer and use it in GitHub Desktop.
AngularJs log HTTP Errors using Sentry
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