I'm having issues getting my HttpInterceptor to work on my application. This is my code:
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req)
.pipe(
catchError((error: HttpErrorResponse) => {
if (error instanceof HttpErrorResponse) {
console.log(error);
let toast: Toast = {
header: "",
body: "",
details: "",
pinned: false,
showDetails: false,
type: ToastTypes.DANGER,
};
switch (error.status) {
...
}
return throwError(error);
}))
)
}
I've tried to use tap() too in my pipe but whenever an error occurs, I only get this on my console:
POST http://localhost:4200/fhir/search 500 (Internal Server Error)
scheduleTask @ zone-evergreen.js:2845
scheduleTask @ zone-evergreen.js:385
onScheduleTask @ zone-evergreen.js:272
scheduleTask @ zone-evergreen.js:378
scheduleTask @ zone-evergreen.js:210
scheduleMacroTask @ zone-evergreen.js:233
scheduleMacroTaskWithCurrentZone @ zone-evergreen.js:1134
(anonymous) @ zone-evergreen.js:2878
proto.<computed> @ zone-evergreen.js:1449
...
Additionally, even if I try to handle errors inside subscribe() blocks, the same behaviour happens and my code is ignored.