mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
global error handling in order to reload page on chunk failed
This commit is contained in:
committed by
Aiden McClelland
parent
9d14d47cfd
commit
db39e4432a
@@ -1,4 +1,4 @@
|
||||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
|
||||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, ErrorHandler } from '@angular/core'
|
||||
import { BrowserModule } from '@angular/platform-browser'
|
||||
import { RouteReuseStrategy } from '@angular/router'
|
||||
import { IonicModule, IonicRouteStrategy, IonNav } from '@ionic/angular'
|
||||
@@ -21,6 +21,7 @@ import { SharingModule } from './modules/sharing.module'
|
||||
import { FormBuilder } from '@angular/forms'
|
||||
import { GenericInputComponentModule } from './modals/generic-input/generic-input.component.module'
|
||||
import { AuthService } from './services/auth.service'
|
||||
import { GlobalErrorHandler } from './services/global-error-handler.service'
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent],
|
||||
@@ -57,6 +58,7 @@ import { AuthService } from './services/auth.service'
|
||||
useFactory: PatchDbServiceFactory,
|
||||
deps: [ConfigService, ApiService, LocalStorageBootstrap, AuthService],
|
||||
},
|
||||
{ provide: ErrorHandler, useClass: GlobalErrorHandler},
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
|
||||
|
||||
13
ui/src/app/services/global-error-handler.service.ts
Normal file
13
ui/src/app/services/global-error-handler.service.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ErrorHandler, Injectable } from '@angular/core'
|
||||
|
||||
@Injectable()
|
||||
export class GlobalErrorHandler implements ErrorHandler {
|
||||
|
||||
handleError (error: any): void {
|
||||
const chunkFailedMessage = /Loading chunk [\d]+ failed/
|
||||
|
||||
if (chunkFailedMessage.test(error.message)) {
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user