title: Retrofit: How do I retry the request again from okhttp interceptor?
body: <p>Ive created an interceptor. In some cases, I want to retry the request 'n' number of time how do i do this?</p>
  <pre><code>class NetworkErrorHandler constructor():  Interceptor {
  
      //Central error handling block for errors which has impact all over the app
      override fun intercept(chain: Interceptor.Chain): Response {
          val request =  chain.request()
          var response = chain.proceed(request) 
  
          return  
              when (response.code) {
                  401 -&gt; { 
                      response
                  }
                  200 -&gt;{  
                      response
                  }
                  else -&gt; { 
                          var tryCount = 0
                          while (tryCount &lt; 3) {
                              try { 
                                  response = chain.proceed(request)
                                  tryCount++
                              }catch (e: java.lang.Exception){
                                  tryCount++
                              }
                          }  
                      response
                  }
              } 
      }
  }
  </code></pre>
  <p>It gives me this error:</p>
  <pre><code>Suppressed: java.lang.IllegalStateException: network interceptor must call proceed() exactly once
  </code></pre>
  <p>Do I have to do this here if yes, then how?</p>