Skip to content

Commit

Permalink
Merge pull request #516 from bcgov/oleks
Browse files Browse the repository at this point in the history
DSS-695: handle errors that occure before the main application has been loaded
  • Loading branch information
ychung-mot authored Aug 8, 2024
2 parents f90c114 + e60f47f commit ca540e9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
14 changes: 13 additions & 1 deletion frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<app-layout *ngIf="currentUserLoaded"></app-layout>
<div *ngIf="!currentUserLoaded">Loading...</div>
<div *ngIf="!currentUserLoaded && !isCurrentUserLoadedWithError">Loading...</div>
<div class="error-block" *ngIf="isCurrentUserLoadedWithError">
<h2 class="error">
Internal error
</h2>
<h3 class="error"> Please try again later</h3>
<h4> If additional support is required, contact us at <a
href="mailto:DSSadmin@gov.bc.ca">{{'DSSadmin@gov.bc.ca'}}</a></h4>
<div class="error-details">
{{errorText}}
</div>
</div>

<div class="loader" *ngIf="isLoading">
<div class="spinner">
<div class="lds-ring">
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
:host {
overflow: auto;

.error-block {
display: flex;
flex-direction: column;
width: 100%;
align-items: center;
}

.loader {
position: fixed;
top: 0;
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class AppComponent implements OnInit {
currentUserLoaded = false;
isLoading = true;
loaderTitle? = 'Loading'
isCurrentUserLoadedWithError = false;
errorText = '';

constructor(
private userService: UserDataService,
Expand All @@ -38,6 +40,15 @@ export class AppComponent implements OnInit {
next: (user) => {
this.currentUserLoaded = !!user;
},
error: (err) => {
if (err.error) {
this.errorText = `${err.error.detail}: ${err.error.instance}`
}

this.isCurrentUserLoadedWithError = true;
this.loaderService.loadingEnd();
this.cd.detectChanges();
},
complete: () => {
this.loaderService.loadingEnd();
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/common/consts/error-interceptor.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const errorInterceptor: HttpInterceptorFn = (req, next) => {
return EMPTY;
case 500:
errorService.showErrorFromBackend(err as any);
return EMPTY;
return throwError(() => err);

default:
break;
Expand Down

0 comments on commit ca540e9

Please sign in to comment.