Skip to content

Commit

Permalink
Merge pull request #758 from liimaorg/feature/757-deployment-log-toas…
Browse files Browse the repository at this point in the history
…t-errors

fix: bugs that caused three toast errors to be shown
  • Loading branch information
yvespp authored Jul 8, 2024
2 parents 8e87bc5 + 1a43a6e commit eebb853
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Failed = 'failed';
selector: 'amw-deployment-log-content',
template: `
<div class="m-2 h-100">
@if (content !== 'failed') {
@if (content !== null && content !== 'failed') {
<div class="h-100">
<ngx-codemirror
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class DeploymentLogsComponent implements OnInit, OnDestroy {
switchMap(this.loadDeploymentLogContent.bind(this)),
);

private error$ = new BehaviorSubject<string>('');
private error$ = new BehaviorSubject<string>(null);

private destroy$ = new Subject<void>();
ngOnInit(): void {
Expand All @@ -120,7 +120,9 @@ export class DeploymentLogsComponent implements OnInit, OnDestroy {
}
this.location.replaceState(`/deployments/${current.id}/logs/${current.filename}`);
});
this.error$.pipe(takeUntil(this.destroy$)).subscribe((msg) => this.toastService.error(msg));
this.error$.pipe(takeUntil(this.destroy$)).subscribe((msg) => {
if (msg !== null) this.toastService.error(msg);
});

CodeMirror.defineSimpleMode('simplemode', {
start: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class HttpToastInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler) {
return next.handle(req).pipe(
catchError((error) => {
console.error('Error in HttpToastInterceptor', error);
this.toastService.error(error.error.message);
return EMPTY;
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function provideGlobalErrorHandler(): Provider[] {
export class GlobalErrorHandler implements ErrorHandler {
toastService = inject(ToastService);
handleError(error: { message: string }): void {
console.error(error);
console.error('Global Error Handler: ' + error);
this.toastService.error(error.message);
}
}

0 comments on commit eebb853

Please sign in to comment.