1. catchError
优雅地处理 observable 序列中的错误(在 catch 函数中返回一个 observable !)
2. retryWhen
当发生错误时,基于自定义的标准来重试 observable 序列
3. retry
4. finalize(等于finally, 结合pit文档中catchError看)
可在 Observable 链的不同位置添加多个 finalize 调用,以确保正确释放多个资源
// 最后一个 finalize 块是在 subscribe value 处理函数和 completion 处理函数之后执行的const http$ = this.http.get<Course[]>('/api/courses');http$.pipe(map(res => res['payload']),catchError(err => {console.log('caught mapping error and rethrowing', err);return throwError(err);}),finalize(() => console.log("first finalize() block executed")),catchError(err => {console.log('caught rethrown error, providing fallback value');return of([]);}),finalize(() => console.log("second finalize() block executed"))).subscribe(res => console.log('HTTP response', res),err => console.log('HTTP Error', err),() => console.log('HTTP request completed.'));
