当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript catchError.catchError函数代码示例

本文整理汇总了TypeScript中rxjs/operators/catchError.catchError函数的典型用法代码示例。如果您正苦于以下问题:TypeScript catchError函数的具体用法?TypeScript catchError怎么用?TypeScript catchError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了catchError函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: readRequest

 protected readRequest(state: State): Observable<HttpResponse<Object>> {
     return this.getDataSource().pipe(
         switchMap(dataSource => dataSource.read(this.getFilterOptions(state))),
         map(data => this.parseDSResponse(data)),
         catchError((error, retry) => _throw(this.getErrorResponse(error)))
     );
 }
开发者ID:telerik,项目名称:kendo-angular2,代码行数:7,代码来源:progress.service.ts

示例2: switchMap

 switchMap((action: ActionStockMarketRetrieve) =>
   this.service
     .retrieveStock(action.payload.symbol)
     .pipe(
       map(stock => new ActionStockMarketRetrieveSuccess({ stock })),
       catchError(error =>
         of(new ActionStockMarketRetrieveError({ error }))
       )
     )
开发者ID:spairo,项目名称:angular-ngrx-material-starter,代码行数:9,代码来源:stock-market.effects.ts

示例3:

 resolveFn: (catalog: CatalogService, state: StateService, loading: TdLoadingService) => {
     loading.register(ConnectorComponent.LOADER);
     return catalog.getConnector(state.transition.params().connectorId)
         .pipe(finalize(() => loading.resolve(ConnectorComponent.LOADER)))
         .pipe(catchError(() => {
             return state.go("catalog.connectors")
         }))
         .toPromise();
 }
开发者ID:prashanthc97,项目名称:kylo,代码行数:9,代码来源:catalog.states.ts

示例4: handleOperation

 protected handleOperation(operation: (dataSource: DataSource) => void): Observable<any> {
     return this.getDataSource().pipe(
         switchMap(dataSource => {
             operation(dataSource);
             return dataSource.saveChanges();
         }),
         catchError((error, retry) => _throw(this.getErrorResponse(error)))
     );
 }
开发者ID:telerik,项目名称:kendo-angular2,代码行数:9,代码来源:progress.service.ts

示例5: switchMap

 switchMap(action =>
   this.service.retrieveStock(action.payload).pipe(
     map(stock => ({
       type: STOCK_MARKET_RETRIEVE_SUCCESS,
       payload: stock
     })),
     catchError(err =>
       of({ type: STOCK_MARKET_RETRIEVE_ERROR, payload: err })
     )
   )
开发者ID:a727891,项目名称:bb,代码行数:10,代码来源:stock-market.effects.ts

示例6: intercept

 intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   const accessToken = this.tokenStoreService.getRawAuthToken(AuthTokenType.AccessToken);
   if (accessToken) {
     request = request.clone({
       headers: request.headers.set("Authorization", `Bearer ${accessToken}`)
     });
     return next.handle(request).pipe(
       catchError((error: any, caught: Observable<HttpEvent<any>>) => {
         console.error({ error, caught });
         if (error.status === 401 || error.status === 403) {
           this.router.navigate(["/accessDenied"]);
         }
         return ErrorObservable.create(error);
       })
     );
   } else {
     // login page
     return next.handle(request);
   }
 }
开发者ID:nogueirawagner,项目名称:jwt-authentication-aspnet-core,代码行数:20,代码来源:auth.interceptor.ts


注:本文中的rxjs/operators/catchError.catchError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。