I would like to intercept 500 error and higher.
I get inspired by:
- angular doc
- AngularJs - $http.get request, response with -1 status code
- and other similar questions
this is the ServiceErrorInterceptor
app.factory('ServerErrorInterceptor',
[ '$q',
function ($q) {
return {
'requestError': function(rejection) {
console.log( rejection );
return $q.reject(rejection);
},
responseError: function (rejection) {
console.log( rejection );
return $q.reject(rejection);
}
};
}
]);
which always returns
Object { data: null, status: -1, headers: headersGetter/<(), config: Object, statusText: "", xhrStatus: "error" }
while [Network] bowser tab shows clearly 400
, 405
, 500
, 503
... depending of the case.
How can I get the http error code?