fix error handler

This commit is contained in:
Dan Percic 2021-07-13 16:03:04 +03:00
parent e16c4d54ff
commit 9382ac0063
2 changed files with 6 additions and 4 deletions

View File

@ -28,7 +28,7 @@ import { UserProfileScreenComponent } from '@components/user-profile/user-profil
import { PlatformLocation } from '@angular/common';
import { BASE_HREF } from './tokens';
import { MONACO_PATH, MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { ChunkLoaderErrorHandler } from '@utils/chunk-loader-error-handler';
import { GlobalErrorHandler } from '@utils/global-error-handler.service';
import { REDMissingTranslationHandler } from '@utils/missing-translations-handler';
export function httpLoaderFactory(httpClient: HttpClient) {
@ -85,7 +85,7 @@ const components = [
providers: [
{
provide: ErrorHandler,
useClass: ChunkLoaderErrorHandler
useClass: GlobalErrorHandler
},
{
provide: BASE_HREF,

View File

@ -1,12 +1,14 @@
import { ErrorHandler, Injectable } from '@angular/core';
@Injectable()
export class ChunkLoaderErrorHandler implements ErrorHandler {
handleError(error: any): void {
export class GlobalErrorHandler extends ErrorHandler {
handleError(error: Error): void {
const chunkFailedMessage = /Loading chunk [\d]+ failed/;
if (chunkFailedMessage.test(error.message)) {
window.location.reload();
}
return super.handleError(error);
}
}