捕获异常 - 捕获和释放

优质
小牛编辑
139浏览
2023-12-01
  1. export class SearchService {
  2. ...
  3. .map((response) => response.json())
  4. .catch((e) => {
  5. if (e.status >== 500) {
  6. return cachedVersion();
  7. new Error(`${ e.status } ${ e.statusText }`)
  8. );
  9. }
  10. });