diff --git a/src/app/ErrorHandler.ts b/src/app/ErrorHandler.ts new file mode 100644 index 0000000..a19f943 --- /dev/null +++ b/src/app/ErrorHandler.ts @@ -0,0 +1,8 @@ +import {ErrorHandler as NgErrorHandler} from "@angular/core"; + + +export class ErrorHandler implements NgErrorHandler { + handleError(error: any): void { + console.warn(error); + } +} diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 42a2071..e26b1ed 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -8,6 +8,8 @@ import localeJap from "@angular/common/locales/en" import {provideHttpClient} from "@angular/common/http"; import {InMemoryWebApiModule} from "angular-in-memory-web-api"; import {HotelDataService} from "./hotel/service/HotelData.service"; +import {ErrorHandler} from "./ErrorHandler"; +import {ErrorHandler as NgErrorHandler} from "@angular/core"; registerLocaleData(localeDe, 'de-DE') registerLocaleData(localeCn, 'cn-CN') @@ -17,6 +19,10 @@ export const appConfig: ApplicationConfig = { provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideHttpClient(), - importProvidersFrom(InMemoryWebApiModule.forRoot(HotelDataService)) + importProvidersFrom(InMemoryWebApiModule.forRoot(HotelDataService)), + { + provide: NgErrorHandler, + useClass: ErrorHandler + } ] }; diff --git a/src/app/hotel/component/edit-hotel.component.ts b/src/app/hotel/component/edit-hotel.component.ts index 262594b..7ee3180 100644 --- a/src/app/hotel/component/edit-hotel.component.ts +++ b/src/app/hotel/component/edit-hotel.component.ts @@ -106,7 +106,9 @@ export class EditHotelComponent implements OnInit { debounce = 0; } - control?.valueChanges?.pipe(debounceTime(debounce)).subscribe(() => {this.setErrorMessage(controlName, control)}); + control?.valueChanges?.pipe(debounceTime(debounce)).subscribe(() => { + this.setErrorMessage(controlName, control) + }); }); }