Angular 如何从订阅错误块中的还原程序获取错误

Angular 如何从订阅错误块中的还原程序获取错误,angular,ngrx,ngrx-store,ngrx-effects,Angular,Ngrx,Ngrx Store,Ngrx Effects,我正在使用ngrx存储并调用API inside effects,如果API失败,我希望在一个操作的子描述中获得错误 范例 this.store.pipe(select(economicEntriesReducer.getEconomicEntries)).subscribe( (response) => { // getting response here if api in effect is successful} (error) => { // how do

我正在使用ngrx存储并调用API inside effects,如果API失败,我希望在一个操作的子描述中获得错误

范例

this.store.pipe(select(economicEntriesReducer.getEconomicEntries)).subscribe(
    (response) => { // getting response here if api in effect is successful}
    (error) => { // how do i make it work });
我从减速器返回状态

导出常量GetEconomicsSupplierGroups=createSelector( getEconomicEntriesState, 状态=>{ 返回状态; } );

实际上就是这样打电话的

return this.httpService.get('economic/entries').pipe(map(
    (response: Supplier[]) => {
        return new economicEntriesActions.GetEntriesSuccess(<Supplier[]>response);
    }),
    catchError(error => of(new economicEntriesActions.GetEntriesError(error)))
);
返回这个.httpService.get('economic/entries').pipe(map(
(回复:供应商[])=>{
返回新的economicEntriesActions.GetEntriesSuccess(响应);
}),
catchError(error=>of(new economicEntriesActions.GetEntriesError(error)))
);

减缩器和选择器不应抛出错误

相反,如果您想处理错误,应该创建一个
getErrors
选择器。 更多信息请访问