Мне нужно получить точное имя компонента, имя функции и номер строки, где произошла ошибка, в файле angular ts, но я не могу получить их из httpInterceptor. Пожалуйста, помогите мне получить вышеуказанное от httpInterceptor.
console.log (this.route.routeConfig.component.name);
Я пробовал описанное выше, и он дает имя компонента текущего рабочего компонента, но мне нужно получить имя компонента из httpInterceptor.
import { Injectable, ErrorHandler, Input } from '@angular/core';
import { catchError, retry} from 'rxjs/operators';
import { Observable, throwError } from 'rxjs';
@Injectable ({ providedIn: 'root' })
export class errorHandler implements HttpInterceptor{
constructor(){
}
intercept(request : HttpRequest<any>, handler : HttpHandler) : Observable<HttpEvent<any>>{
return handler.handle(request)
.pipe(
retry(1),
catchError((error : any) => {
console.log('---->'+request.headers.get('content-disposition'));
let errorMessage = '';
if(error.error instanceof ErrorEvent)
errorMessage = `Error : `+error.error.message;
else
errorMessage = `Error Code : `+error.status +`\nMessage : `+error.message;
return throwError(JSON.stringify(errorMessage));
})
)
}
}```