Angular error handling
Angular
private errorSubject = new Subject<string>();
error$ = this.errorSubject.asObservable();
product$ = this.productService.selectedProduct$.pipe(
catchError((err) => {
this.errorSubject.next(err);
return EMPTY;
}),
);
<div *ngIf="error$ | async as errorMessage">{{ errorMessage }}</div>