title: Android, Retrofit catch specific response code for all requests
body: <p>I have Retrofit Rest client interface with more than 40 http calls. I initialize my RestClient like this:</p>
  
  <pre><code>public class RestClient {
  
      private static final String BASE_URL = "http://example.com/";
  
      private static final int TIMEOUT_IN_SECONDS = 30;
  
      private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
          .addInterceptor(getInterceptor())
          .connectTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
          .readTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
          .writeTimeout(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS)
          .build();
  
  
      private static Retrofit retrofit = new Retrofit.Builder()
          .baseUrl(BASE_URL)
          .client(okHttpClient)
          .addConverterFactory(GsonConverterFactory.create())
          .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
          .build();
  
      private RestClient() {
  
      }
  
      private static HttpLoggingInterceptor getInterceptor() {
      HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
      interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY
              : HttpLoggingInterceptor.Level.NONE);
          return interceptor;
      }
  
      public static MyService request() {
          return retrofit.create(MyService.class);
      }
  
  }
  </code></pre>
  
  <p>All requests, except authorization, requires special token. When this token expires REST API responds with <code>403</code> code error.</p>
  
  <p>I can't add checking for this code response from each of my API call, because there are more than 100 api calls in my application.</p>
  
  <p>Is it possible to somehow catch <code>403 response code</code> in the level of my <code>RestClient</code> class so I could open Authorization Activity again?</p>