Package 

Class EmbraceOkHttp3ApplicationInterceptor

  • All Implemented Interfaces:
    okhttp3.Interceptor

    
    public class EmbraceOkHttp3ApplicationInterceptor
     implements Interceptor
                        

    This interceptor will only intercept errors that client app experiences.

    We used OkHttp3 application interceptor in this case because this interceptor will be added first in the OkHttp3 interceptors stack. This allows us to catch network errors. OkHttp3 network interceptors are added almost at the end of stack, they are closer to "Wire" so they are not able to see network errors.

    Application interceptors: - Don't need to worry about intermediate responses like redirects and retries. - Are always invoked once, even if the HTTP response is served from the cache. - Observe the application's original intent. Unconcerned with OkHttp-injected headers like If-None-Match. - Permitted to short-circuit and not call Chain.proceed(). - Permitted to retry and make multiple calls to Chain.proceed().

    We used the EmbraceGraphQLException to capture the custom path added in the intercept chain process for client errors on graphql requests.

    • Method Summary

      Modifier and Type Method Description
      Response intercept(Interceptor.Chain chain)
      • Methods inherited from class okhttp3.Interceptor

        intercept
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EmbraceOkHttp3ApplicationInterceptor

        EmbraceOkHttp3ApplicationInterceptor()
    • Method Detail

      • intercept

         Response intercept(Interceptor.Chain chain)