I've written a code in which I would like to catch an error when exception occurs:
this.assetApiService.getAssets(new AssetSearchCriteriaDto({tags: [AssetTags.tenant]})).pipe(
catchError(error => {
console.log(error);
}),
(mergeMap((assets: AssetDto[]) => {
this.appInitStorageService.setAvailableTenants(assets);
return this.userApiService.getUserById(this.authApiService.getAuth().userInfo.id);
}
)
)
)
.subscribe((user: UserDto) => {
this.persistSelectedUserLanguage(user);
this.appInitStorageService.setUser(user);
resolve();
}, error => {
console.log('error:', error);
});
The goal is to catch errors either if they occur from first observable in sequence(getAssets) or in second observable(getUserById). I've added catchError operator in first one but I can't see console.log(error). I don't know why. How should I properly catch errors in this example?