title: Angular HttpInterceptor modifies the error object
body: <p>I've implemented an <code>HttpInterceptor</code> that adds a header to each requests and redirects to the login page if server responded with <code>401</code>. I don't want it to do anything else.</p>
  
  <p>I'm noticing however that whenever I get a bad response from the server (as I expect it), the interceptor kicks it and throws the <code>HttpErrorResponse</code>. However in my controller I get only a <code>TypeError</code> object without the details from the server.</p>
  
  <p>I'm attaching the relevant code.</p>
  
  <p><em>Interceptor</em></p>
  
  <pre><code>@Injectable()
  export class HttpAuthorizationService implements HttpInterceptor {
  
    constructor(private cookieService: CookieService, private angularRouter: Router) { }
  
    intercept(req: HttpRequest&lt;any&gt;, next: HttpHandler):  Observable&lt;HttpEvent&lt;any&gt;&gt; {
      req = req.clone({
        setHeaders: {
          Authorization: 'Bearer ' + this.cookieService.get('Authorization')
        }
      });
  
      return next.handle(req).do((ev: HttpEvent&lt;any&gt;) =&gt; {})
      .catch(error =&gt; {
        if (error instanceof HttpErrorResponse) {
          if (error.status === 401) {
            this.cookieService.set('expired', 'Session expired');
            this.angularRouter.navigate(['/login']);
          }
        }
        return Observable.throw(error); &lt;-- i think this is bad
      });
    }
  }
  </code></pre>
  
  <p>and actual <em>controller</em></p>
  
  <pre><code>deleteCategory(category) {
  this.confirmationService.confirm({
    message: 'Are you sure you want to delete?',
    header: 'Delete product category ' + category,
    icon: 'fa fa-trash',
    accept: () =&gt; {
      this.productService.deleteCategory(category).subscribe(
        success =&gt; {
          this.msgs = [{ severity: 'success', summary: 'Success', detail: 'Successfully deleted the product category ' + category }];
        },
        error =&gt; {
          this.categories.push(category);
          this.msgs = [{ severity: 'error', summary: 'Could not delete category', detail: error.status + '-' + error.error }]; &lt;-- getting object without error attribute and no info from the server
        }
      );
    },
    reject: () =&gt; this.categories.push(category)
  });
  </code></pre>
  
  <p>}</p>
  
  <p>My question is how to i keep the original error object instead of what im actually getting
  if i don't implements this HttpInterceptor than my controllers gets the normal error object</p>