Skip to content

Commit

Permalink
Merge pull request #1045 from griffithlab/dont-suppress-errors
Browse files Browse the repository at this point in the history
Don't swallow errors in development mode
  • Loading branch information
acoffman authored Apr 26, 2024
2 parents fc82652 + 6be3f49 commit 4162888
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { GraphQLModule } from '@app/graphql/graphql.module'
import { NzIconModule } from 'ng-zorro-antd/icon'
import { CvcNetworkErrorAlertModule } from './components/app/network-error-alert/network-error-alert.module'
import { Observable } from 'rxjs'
import { AppLoadErrorHandler } from './core/utilities/app-reload-handler'
import { AppErrorHandler } from './core/utilities/app-error-handler'
import { CvcForms2Module } from '@app/forms/forms.module'

registerLocaleData(en)
Expand Down Expand Up @@ -59,7 +59,7 @@ function initializeApiFactory(httpClient: HttpClient): () => Observable<any> {
CookieService,
{
provide: ErrorHandler,
useClass: AppLoadErrorHandler,
useClass: AppErrorHandler,
},
{ provide: NZ_I18N, useValue: en_US },
{
Expand Down
22 changes: 22 additions & 0 deletions client/src/app/core/utilities/app-error-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ErrorHandler, Injectable } from '@angular/core'
import { environment } from 'environments/environment'

@Injectable()
export class AppErrorHandler implements ErrorHandler {
handleError(error: any): void {
if (environment.production) {
const chunkFailedMessage = /Loading chunk [\d]+ failed/
if (chunkFailedMessage.test(error.message)) {
if (
confirm(
'There is an updated version of CiVIC available. Click OK to reload.'
)
) {
window.location.reload()
}
}
} else {
console.error(error)
}
}
}
17 changes: 0 additions & 17 deletions client/src/app/core/utilities/app-reload-handler.ts

This file was deleted.

0 comments on commit 4162888

Please sign in to comment.