當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript throwError.throwError函數代碼示例

本文整理匯總了TypeScript中rxjs/internal/observable/throwError.throwError函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript throwError函數的具體用法?TypeScript throwError怎麽用?TypeScript throwError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了throwError函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should not decrease quantity on error retrieving basket item and log the error', fakeAsync(() => {
   basketService.get.and.returnValue(throwError('Error'))
   console.log = jasmine.createSpy('log')
   component.dec(1)
   expect(console.log).toHaveBeenCalledWith('Error')
   expect(basketService.put).not.toHaveBeenCalled()
 }))
開發者ID:bkimminich,項目名稱:juice-shop,代碼行數:7,代碼來源:basket.component.spec.ts

示例2: concatMap

 concatMap(chapter => {
     if (chapter === 3) {
         return throwError(new Error('Forced error!'));
     } else {
         return story.getChapter(chapter);
     }
 }),
開發者ID:MarcoLeko,項目名稱:async-patterns,代碼行數:7,代碼來源:stories-usage.ts

示例3: handleError

 private handleError(errResp: HttpErrorResponse | any) {
     let errMsg: any;
     if (errResp instanceof HttpErrorResponse) {
         switch (errResp.status) {
             case 401:
                 // handle Unauthorized error and redirect to login page
                 errMsg = '401 Unauthorized';
                 console.log(this.router.url);
                 if (this.router.url !== '/login') {
                     this.router.navigate(['/login']);
                 }
                 break;
             case 403:
                 errMsg = '403 Forbidden';
                 console.log();
                 if (errResp.error['code'] === 1) {
                     this.router.navigate(['/login']);
                 } else {
                     this.message.warning('沒有權限');
                 }
                 break;
             default:
                 // this.message.error('請求錯誤');
                 break;
         }
     } else {
         errMsg = 'Request Error';
     }
     return throwError(errResp.error as HttpError);
 }
開發者ID:yangjinguang,項目名稱:liyu,代碼行數:30,代碼來源:http-client.ts

示例4: it

  it('should give an error if FeedbackService fails to delete feedback', fakeAsync(() => {
    feedbackService.del.and.returnValue(throwError('Error'))
    component.deleteFeedback(1)

    tick()

    expect(component.error).toBe('Error')
  }))
開發者ID:bkimminich,項目名稱:juice-shop,代碼行數:8,代碼來源:administration.component.spec.ts

示例5: it

  it('should show an error if indices could not be activated', () => {
    const service = fixture.debugElement.injector.get(IndexService);
    indexServiceStub.setActive.and.returnValue(throwError('fake error'));

    fixture.detectChanges();
    shouldShowError(element, 'fake error');

  });
開發者ID:informationgrid,項目名稱:ingrid-ibus,代碼行數:8,代碼來源:list-indices.component.spec.ts


注:本文中的rxjs/internal/observable/throwError.throwError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。