[QUESTION] Is there a way to override the global error interceptor from individual calls
I am setting a global error interceptor in my config function but I was hoping that I can override this is if needed on per request basis.
If I understand correctly the response will always be intercepted by the error interceptor that I have in the config and then by the interceptor I have on my individual call.
I was wondering if there is a way to reverse this.
The only other possible solution I can think of is to not set the global error interceptor and individually set interceptor of each of the restangular calls.
I'm curious about this too as it seems a more natural approach.
I read http://stackoverflow.com/questions/28010548/restangular-how-to-override-error-interceptors but it doesn't really address the underlying issue. The most intuitive approach is for global error interceptor to trigger last (i.e. Specific_ErrorHandler (if Exists) > ErrorInterceptor > End).
See https://github.com/mgonto/restangular/issues/566
Without having investigated this at all, my intuition has a hard time imagining how the error interceptors could be executed after the context specific error handlers. I agree that it perhaps would make more sense, but given the nature of the promise mechanism and the data flow being somewhat like this:
CALL: context -> restangular -> $http -> HTTP request
REPONSE: HTTP response -> $http -> restangular -> "internal" error interceptor -> context
I don't see how the proposed flow would be possible, not to mention clean and tidy.
Any suggestions in form of PRs are most welcome, though!
Sorry, I'm not really familiar with the code base, but wouldn't it be a matter of changing the order of these statements:
https://github.com/mgonto/restangular/blob/master/src/restangular.js#L1287-L1292
That is to say, invoke
deferred.reject(response)
before
.every(config.errorInterceptors, function(cb) {
return cb(response, deferred, okCallback) !== false;
})