Intercepting error messages using restangular

I am trying to create an interceptor for all requests. I decided to use [addResponseInterceptor][1] of restangular.

It says

The responseInterceptor is called after we get each response from the server.

I used this function to create the interceptor.

        rest.addResponseInterceptor(function (data, operation, what, url, response, deferred) {
            console.log(url);
            return data;
        });

But this isn't intercept error requests. eg 500. Am I doing something wrong? or the addResponseInterceptor is made to just work for 200 responses ?

Not really familiar with restangular but in angular incerceptors there is different callback for normal responce and for error. So you are interception normal response. I belive you need to write another callback function and use setErrorInterceptor to make it handle error responses