import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpErrorResponse, } from '@angular/common/http'; import { Observable, throwError } from 'rxjs'; import { catchError, retry } from 'rxjs/operators'; import { NGXLogger } from 'ngx-logger'; import { Injectable } from '@angular/core'; @Injectable() export class HttpErrorInterceptor implements HttpInterceptor { constructor(private logger: NGXLogger) { } intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request) .pipe( catchError((error: HttpErrorResponse) => { this.logger.error([error, request]); return throwError(error); }) ); } }