import { Injectable , Injector } from '@angular/core' ; import { HttpEvent , HttpInterceptor , HttpHandler , HttpRequest , HttpErrorResponse } from '@angular/common/http' ; import { Observable , throwError } from 'rxjs' ; import { catchError } from 'rxjs/operators' ; @ Injectable ( ) export class ErrorInterceptor implements HttpInterceptor { constructor ( ) { } intercept ( req , next ) { return next . handle ( req ) . pipe ( catchError ( this . handleError ) ) ; } public handleError = ( errorRes ) => { const { error : { status , error , message } , } = errorRes ; console . error ( `Backend Error ! status: ${ status }, error: ${ error }, message: ${ message }` ) ; return throwError ( errorRes ) ; } ; }