【发布时间】:2018-04-03 17:28:19
【问题描述】:
myfunc() {
const combined = forkJoin(
this.service.fn1(parameter).pipe(
catchError(err => {
throw (this.handleError(err));
}),
),
this.service2.fn2().pipe(
catchError(err =>
//i need to ignore this error and execute final result,
),
this.service3.fn3().pipe(
catchError(err => // Need to ignore this error too and continue)
));
const subscribe = combined.subscribe (
([fn1,fn2,fn3]) => {
//execute this part even if fn2, fn3 call fails. How can i do ??
}
);
}
如何忽略在 service2.fn2() 和 service3.fn3() 中捕获的错误并执行最后一部分?
我是新手,如有任何帮助,我们将不胜感激。
我看到了这个链接,但我没有完全理解。如果有人能简单地说出来,那就太好了。
【问题讨论】:
-
只需在
catchError中返回empty(),例如:catchError(() => empty()) -
不要在 catch 错误中抛出错误
-
@martin 如果我添加 empty(),它不会执行最终结果部分!
-
@Ricardo 我需要为函数 1 显示不同的输出,所以我在那里抛出并执行一些操作。有没有其他办法?
标签: angular error-handling rxjs fork-join