import { Injectable } from '@angular/core' ; import { JhiEventManager } from 'ng-jhipster' ; import { HttpInterceptor , HttpRequest , HttpErrorResponse , HttpHandler , HttpEvent } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { tap } from 'rxjs/operators' ; @ Injectable ( ) export class ErrorHandlerInterceptor implements HttpInterceptor { constructor ( private eventManager ) { } intercept ( request , next ) { return next . handle ( request ) . pipe ( tap ( ( event ) => { } , ( err ) => { if ( err instanceof HttpErrorResponse ) { if ( ! ( err . status === 401 && ( err . message === '' || ( err . url && err . url . includes ( '/api/account' ) ) ) ) ) { this . eventManager . broadcast ( { name : 'frontendApp.httpError' , content : err } ) ; } } } ) ) ; } }