title: Unable to handle HTTP/404 when calling httpClient.delete() in Angular 8
body: <p>I have Springboot 2.1 endpoint that returns HTTP/404 when calling DELETE method. 
  There is Angular 8 application that calls that endpoint using HttpClient. It has been stripped down to simplest possible code.</p>
  
  <p>If I call <strong>httpClient.delete('url').subscribe();</strong> while backend returns HTTP/404 I'm unable to handle errors. 
  Angular throws this error in console: <em>ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.</em></p>
  
  <p>I tried handling errors as it's written in Angular http client description but it does not help. Before any error handling code is called, Angular throws error in console and no error handling is executed.</p>
  
  <p>Here's the Java code</p>
  
  <pre class="lang-java prettyprint-override"><code>@RestController
  @RequestMapping("/api/test")
  @RequiredArgsConstructor
  class TestController {
  
    @DeleteMapping("/{id}")
    public ResponseEntity deleteObject(@PathVariable("id") Long id) {
      return ResponseEntity.notFound().build();
    }
  }
  </code></pre>
  
  <p>Angular code calling this endpoint is:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  
  @Injectable()
  export class ObjectsService {
  
    constructor(private httpClient: HttpClient) {
    }
  
    deleteObject() {
      return this.httpClient.delete('http://localhost:8090/api/test/5').subscribe();
    }
  }
  </code></pre>
  
  <p>Chrome shows that the response is:</p>
  
  <pre><code>Request URL: http://localhost:8090/api/test/5
  Request Method: DELETE
  Status Code: 404 
  Remote Address: [::1]:8090
  Referrer Policy: no-referrer-when-downgrade
  </code></pre>
  
  <p>Unfortunately instead of normal execution I'm getting an error in the console:</p>
  
  <pre><code>ERROR TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
      at subscribeTo (subscribeTo.js:27)
      at subscribeToResult (subscribeToResult.js:11)
      at CatchSubscriber.error (catchError.js:38)
      at XMLHttpRequest.onLoad (http.js:2476)
      at ZoneDelegate.invokeTask (zone-evergreen.js:391)
      at Object.onInvokeTask (core.js:39679)
      at ZoneDelegate.invokeTask (zone-evergreen.js:390)
      at Zone.runTask (zone-evergreen.js:168)
      at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:465)
      at invokeTask (zone-evergreen.js:1603)
  </code></pre>
  
  <p>edit:
  There is also HTTPInterceptor that was handling errors:</p>
  
  <pre><code>  private handleErrors(err: HttpErrorResponse): Observable&lt;any&gt; {
      if (err.status === 401) {
        this.loginService.redirectToUrl = this.router.url;
        this.router.navigate(['/login']);
        return of(err.message);
      }
    }
  </code></pre>
  
  <p>Thanks to @igor, "missing else" was spotted. Adding HTTP/404 handling in interceptor solved this problem.</p>