diff --git a/libs/vre/shared/app-error-handler/src/lib/app-error-handler.ts b/libs/vre/shared/app-error-handler/src/lib/app-error-handler.ts index f57ea9904e..1e60654b1e 100644 --- a/libs/vre/shared/app-error-handler/src/lib/app-error-handler.ts +++ b/libs/vre/shared/app-error-handler/src/lib/app-error-handler.ts @@ -1,6 +1,7 @@ import { HttpErrorResponse } from '@angular/common/http'; import { ErrorHandler, Injectable } from '@angular/core'; import { ApiResponseError } from '@dasch-swiss/dsp-js'; +import { AppConfigService } from '@dasch-swiss/vre/shared/app-config'; import { NotificationService } from '@dasch-swiss/vre/shared/app-notification'; import { AjaxError } from 'rxjs/ajax'; @@ -8,7 +9,10 @@ import { AjaxError } from 'rxjs/ajax'; providedIn: 'root', }) export class AppErrorHandler implements ErrorHandler { - constructor(private _notification: NotificationService) {} + constructor( + private _notification: NotificationService, + private readonly _appConfig: AppConfigService + ) {} handleError(error: any): void { if (error instanceof ApiResponseError && error.error instanceof AjaxError) { @@ -17,8 +21,7 @@ export class AppErrorHandler implements ErrorHandler { } else if (error instanceof HttpErrorResponse) { // ApiServices this.handleHttpErrorResponse(error); - } else { - // TODO in future: only display if environment === 'prod', now even local is configured as 'prod' + } else if (this._appConfig.dspInstrumentationConfig.environment !== 'prod') { console.error(error); } }