Skip to content

Commit

Permalink
fix: dont show errors on prod
Browse files Browse the repository at this point in the history
  • Loading branch information
derschnee68 committed Jan 30, 2024
1 parent a89d5df commit 642f543
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
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';

@Injectable({
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) {
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 642f543

Please sign in to comment.