This in my interceptor
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req)
.catch(err => {
if (err instanceof HttpErrorResponse) {
this.errorControl(req, err.status);
return Observable.throw(err);
}
});
}
I need to catch the error sent from the server in my component since I have to act accordingly (404: return to last url, 400: show a message, etc). When I catch the error in the subscription to the observable I get this
"You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable."
but I need a HttpErrorResponse with its status, status text, etc.
Removing the interceptor solves my problem, but I need it for all the session stuff.
errorControl(req, err.status)function ? - user4676340