Angular.js $http intercept “net::ERR_CONNECTION_REFUSED”

You can probably check the status of the ResponseError. When an API is offline that is 0 (until Angular 1.3.18) or -1 (since Angular 1.3.19): angular.module(“services.interceptor”, arguments).config(function($httpProvider) { $httpProvider.interceptors.push(function($q) { return { responseError: function(rejection) { if(rejection.status <= 0) { window.location = “noresponse.html”; return; } return $q.reject(rejection); } }; }); });

Spring MVC 3, Interceptor on all excluding some defined paths

Since Spring 3.2 they added that feature with the tag mvc:exclude-mapping See this example from the Spring documentation: <mvc:interceptors> <bean class=”org.springframework.web.servlet.i18n.LocaleChangeInterceptor” /> <mvc:interceptor> <mvc:mapping path=”/**”/> <mvc:exclude-mapping path=”/admin/**”/> <bean class=”org.springframework.web.servlet.theme.ThemeChangeInterceptor” /> </mvc:interceptor> <mvc:interceptor> <mvc:mapping path=”/secure/*”/> <bean class=”org.example.SecurityInterceptor” /> </mvc:interceptor> Here’s the link to the doc

GNU gcc/ld – wrapping a call to symbol with caller and callee defined in the same object file

You have to weaken and globalize the symbol using objcopy. -W symbolname –weaken-symbol=symbolname Make symbol symbolname weak. This option may be given more than once. –globalize-symbol=symbolname Give symbol symbolname global scoping so that it is visible outside of the file in which it is defined. This option may be given more than once. This worked … Read more

Automating access token refreshing via interceptors in axios

I may have found a way much simpler to handle this : use axios.interceptors.response.eject() to disable the interceptor when I call the /api/refresh_token endpoint, and re-enable it after. The code : /** * Wrap the interceptor in a function, so that i can be re-instantiated */ function createAxiosResponseInterceptor() { const interceptor = axios.interceptors.response.use( (response) => … Read more

AngularJS Intercept all $http JSON responses

You can intercept responses by adding an interceptor to $httpProvider.interceptors with Angular 1.1.4+ (see documentation here search for interceptors). For a specific content type like json you can potentially reject changes or throw an exception even if the call was a success. You can modify the response.data that will get passed to your controller code … Read more

Android Retrofit 2, differences between addInterceptor & addNetworkInterceptor for editing responses

The differences are in the names. NetworkInterceptor hooks in at the network level and is an ideal place to put retry logic and anything that doesn’t rely on the actual content of the response. If what you do depends on the contents of the response (like in your case), using a ApplicationInterceptor is more useful, … Read more

Handle exceptions thrown by a custom okhttp Interceptor in Kotlin Coroutines

You should subclass IOException and use that to send information from your interceptors to your calling code. We consider other exceptions like IllegalStateException to be application crashes and do not send them over thread boundaries because we don’t want to burden most callers with catching them.