I have a global error handler in my Angular application.
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
constructor(private globalErrorService: GlobalErrorService) {}
public handleError(error: Error | HttpErrorResponse) {
const isHttpError = error instanceof HttpErrorResponse;
if (!isHttpError) {
this.logError(error);
}
}
public logError(error: Error) {
const errorLog = new GlobalErrorModel();
errorLog.message = error.message;
errorLog.name = error.name;
errorLog.stack = error.stack;
errorLog.url = window.location.href;
this.globalErrorService.logError(errorLog).subscribe();
}
}
It's working perfectly but the issue is sometimes chrome-extension error also got caught by this handler, and I keep getting error alert from only one user because the user is using this random extension that has nothing to do with the application. How can we exempt chrome-extension errors from this handler?