I am trying to use an Angular interceptor for handling my 500
or 403
error codes. For other codes I have custom business implementation. However it seems using interceptor makes Angular treat error responses as success responses and my success callback in .then
is called. Isn't this strange, considering docs which says 200-299 codes are only treated as success response.
My code:
function appInterceptorFn(){
var interceptor = {
responseError: function (config) {
if (config && config.status === cramConfig.FORBIDDEN_ACCESS_CODE) {
$rootScope.$emit('ERROR_EVENT', config);
}
return config;
}
}
return interceptor;
}
Is there something that can be done to avoid it, I am using AngularJS v1.3.17
I have visited this link which shows a different implementation but I would like to use interceptor preferably.
Is this a known issue ?