const obs1$ = this.service.getAllItems();
const obs2$ = this.service.getItemById(1);
combineLatest([obs1$, obs2$])
.subscribe(pair => {
const items = pair[0];
const item = pair[1];
// perform actions
}, err => {
// determine which observable caused the error
if (err.status === 404) {
// handle error for second observable
this.utilsService.alert('Item with id 1 not found');
}
if (err.status === 500) {
// handle error for first observable
}
});
In my backend responses, a 404 status
is never sent for retrieving a list. Therefore, in this scenario, I can infer that the 404
error originated from the second observable. However, if there is a need for additional handling based on the source of the error within the error
method, how can this be achieved? Thank you.