title: Angular8 HttpInterceptor return value
body: <p>I have a basic HttpInterceptor in which I am using the rxjs retryWhen in order to retry a certain number of times if there are service failures. If the service call has reached the maximum retry amount then I would like to feed this back to the method that originally instigated the service call.</p>
  
  <p>My question is, how can I return control back to the original instigator of the http call?
  I need to do this in order to centralise control of handling retries in a single place (the interceptor) and I would like to be able to call back to a success/failure method in the calling function.</p>
  
  <p>My problem is that the error is swallowed by the global error handler and nothing gets passed back to my caller.</p>
  
  <p>Example:</p>
  
  <pre class="lang-js prettyprint-override"><code>this.MyServiceCall()
          .pipe(
            map((result) =&gt; {
              console.log('this is called when the service returns success');
            }),
           )
           // If there is an error, then how can I show it?
        })
      }
  
  
  export class HttpRetryInterceptorService implements HttpInterceptor {
    constructor() { }
  
    intercept(req: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
      return next.handle(req).pipe(
          retryWhen(errors =&gt; errors
              .pipe(
              concatMap((err:HttpErrorResponse, count) =&gt; iif(
              () =&gt; (count &lt; 3),
              of(err).pipe(
                  map(()=&gt;{
                      console.log(count.toString())
                  }),
                  delay((2 + Math.random()) ** count * 200)),
                  throwError(err)
              ))
          ))
      );
    }
  }
  </code></pre>