title: Angular HttpInterceptor Ignore a Specific HttpErrorResponse Status
body: <p>I have an HttpInterceptor that is functional. It has limited responsibilities thus far in that I am only catching HttpErrorResponse. I want status code 404 to just be ignored so that the calling service can decide how to handle the error. I have tried a few different approaches. </p>
  
  <p>If I leave the if block blank, so that the interceptor does nothing, the catch in the service results in a "You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable." error message.</p>
  
  <p>If I have the interceptor return an Observable.of(errorResponse), see below, the http.get call's catch is never hit.</p>
  
  <p>If I don't register the interceptor at all, the service works as expected but that doesn't help as I am going to be evolving what this interceptor does.</p>
  
  <p><strong>Interceptor</strong></p>
  
  <pre><code>intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
  
  return next.handle(request)        
    .catch((errorResponse: HttpErrorResponse) =&gt; {
  
      if (errorResponse.status === 404) {
          return Observable.of(errorResponse);
      } else if (errorResponse.status === 401) {
          this.windowRef.location.href = this.windowRef.location.href;
      } else {
          console.error(errorResponse);
  
          let errorMessage: string = '';
  
          for (const error of errorResponse.error) {
              errorMessage += error.message + '&lt;br/&gt;';
          }
  
          return Observable.throw(errorMessage || 'Server Error');
      }
    });
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Service</strong></p>
  
  <pre><code>return this.http
  .get&lt;any&gt;(integrationsApiUrl, { withCredentials: true })
  .catch((errorResponse: any) =&gt; {      
    if (errorResponse.status === 404) {
      return Observable.throw('No setup data could be found.');
    }
  });
  </code></pre>