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


TypeScript rxjs.throwError函數代碼示例

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


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

示例1: catchError

 catchError(err =>
   throwError(new HttpException('Message', HttpStatus.BAD_GATEWAY)),
開發者ID:SARAVANA1501,項目名稱:nest,代碼行數:2,代碼來源:exception.interceptor.ts

示例2: catchError

 catchError((err) => throwError(err))
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:1,代碼來源:nodes-api.service.ts

示例3: catchError

 catchError(_ => throwError(new Error('Unable to get titles')))
開發者ID:tobihagemann,項目名稱:shitishot,代碼行數:1,代碼來源:game.service.ts

示例4: throwError

 a: [() => throwError('err'), () => of(FIXTURE_RESULT)],
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:1,代碼來源:hover.test.ts

示例5: flatMap

 flatMap(value =>
   typeof value !== 'number'
     ? throwError(`Value "${value}" is not a valid number.`)
     : of(value)
開發者ID:jesuscc1993,項目名稱:demos,代碼行數:4,代碼來源:retryWhen.ts

示例6: write

 write(_path: Path, _content: virtualFs.FileBufferLike) {
   return throwError(new Error('Not supported.'));
 }
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:3,代碼來源:webpack-input-host.ts

示例7: rename

 rename(_from: Path, _to: Path) {
   return throwError(new Error('Not supported.'));
 }
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:3,代碼來源:webpack-input-host.ts

示例8: it

 it('should consume errors encountered when loading start form', () => {
     getStartFormSpy.and.returnValue(throwError({}));
     component.processDefinitionId = exampleId1;
     component.ngOnInit();
 });
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:5,代碼來源:start-form.component.spec.ts

示例9: onInput


//.........這裏部分代碼省略.........
            });

            // We don't want to subscribe errors and complete.
            subscriptions.push(run.progress.subscribe(event => progressChannel.next(event)));

            return run;
          },
          async scheduleBuilder(
            builderName: string,
            options: json.JsonObject = {},
            scheduleOptions: ScheduleOptions = {},
          ) {
            const run = await scheduleByName(builderName, options, {
              scheduler,
              logger: scheduleOptions.logger || logger.createChild(''),
              workspaceRoot: i.workspaceRoot,
              currentDirectory: i.currentDirectory,
            });

            // We don't want to subscribe errors and complete.
            subscriptions.push(run.progress.subscribe(event => progressChannel.next(event)));

            return run;
          },
          async getTargetOptions(target: Target) {
            return scheduler.schedule<Target, json.JsonValue, json.JsonObject>(
                    '..getTargetOptions', target).output.toPromise();
          },
          async getBuilderNameForTarget(target: Target) {
            return scheduler.schedule<Target, json.JsonValue, string>(
              '..getBuilderNameForTarget',
              target,
            ).output.toPromise();
          },
          async validateOptions<T extends json.JsonObject = json.JsonObject>(
            options: json.JsonObject,
            builderName: string,
          ) {
            return scheduler.schedule<[string, json.JsonObject], json.JsonValue, T>(
              '..validateOptions',
              [builderName, options],
            ).output.toPromise();
          },
          reportRunning() {
            switch (currentState) {
              case BuilderProgressState.Waiting:
              case BuilderProgressState.Stopped:
                progress({ state: BuilderProgressState.Running, current: 0, total  }, context);
                break;
            }
          },
          reportStatus(status: string) {
            switch (currentState) {
              case BuilderProgressState.Running:
                progress({ state: currentState, status, current, total  }, context);
                break;
              case BuilderProgressState.Waiting:
                progress({ state: currentState, status }, context);
                break;
            }
          },
          reportProgress(current: number, total?: number, status?: string) {
            switch (currentState) {
              case BuilderProgressState.Running:
                progress({ state: currentState, current, total, status }, context);
            }
          },
          analytics: new analytics.ForwardingAnalytics(report => analyticsChannel.next(report)),
          addTeardown(teardown: () => (Promise<void> | void)): void {
            teardownLogics.push(teardown);
          },
        };

        context.reportRunning();
        let result: BuilderOutputLike;
        try {
          result = fn(i.options as OptT, context);
        } catch (e) {
          result = throwError(e);
        }

        if (isPromise(result)) {
          result = from(result);
        } else if (!isObservable(result)) {
          result = of(result);
        }

        // Manage some state automatically.
        progress({ state: BuilderProgressState.Running, current: 0, total: 1 }, context);
        subscriptions.push(result.pipe(
          tap(() => {
            progress({ state: BuilderProgressState.Running, current: total }, context);
            progress({ state: BuilderProgressState.Stopped }, context);
          }),
        ).subscribe(
          message => observer.next(message as OutT),
          error => observer.error(error),
          () => observer.complete(),
        ));
      }
開發者ID:angular,項目名稱:angular-cli,代碼行數:101,代碼來源:create-builder.ts

示例10: throwError

 erroringService.addStudent.and.callFake(() => throwError('service error'));
開發者ID:vgebrev,項目名稱:Tesli,代碼行數:1,代碼來源:student-detail.component.spec.ts


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