Skip to content

Commit

Permalink
Improve error box developer experience (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen authored May 9, 2024
1 parent 319f4f5 commit 0969908
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions mesop/web/src/shell/shell.ng.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@for(error of this.errors; track $index) {
<mesop-error-box *ngIf="error != null" [error]="error" />
}

<div class="status">
<mat-progress-bar
data-testid="connection-progress-bar"
Expand Down
7 changes: 4 additions & 3 deletions mesop/web/src/shell/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {GlobalErrorHandlerService} from '../services/global_error_handler';
})
export class Shell {
rootComponent!: ComponentProto;
errors: ServerError[] = [];
error: ServerError | undefined;
componentConfigs: readonly ComponentConfig[] = [];

constructor(
Expand All @@ -57,7 +57,7 @@ export class Shell {
(errorHandler as GlobalErrorHandlerService).setOnError((error) => {
const errorProto = new ServerError();
errorProto.setException(`JS Error: ${error.toString()}`);
this.errors.push(errorProto);
this.error = errorProto;
});
}

Expand All @@ -67,12 +67,13 @@ export class Shell {
onRender: (rootComponent, componentConfigs) => {
this.rootComponent = rootComponent;
this.componentConfigs = componentConfigs;
this.error = undefined;
},
onNavigate: (route) => {
this.router.navigateByUrl(route);
},
onError: (error) => {
this.errors.push(error);
this.error = error;
},
});
}
Expand Down

0 comments on commit 0969908

Please sign in to comment.