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


TypeScript PromiseWrapper.catchError方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/async.PromiseWrapper.catchError方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PromiseWrapper.catchError方法的具体用法?TypeScript PromiseWrapper.catchError怎么用?TypeScript PromiseWrapper.catchError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/async.PromiseWrapper的用法示例。


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

示例1: expect

 tcb.createAsync(AppCmp).then((fixture) => {
   var router = fixture.debugElement.componentInstance.router;
   PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
     expect(error).toContainError('oops!');
     async.done();
   });
 });
开发者ID:LordBinary,项目名称:angular,代码行数:7,代码来源:bootstrap_spec.ts

示例2: it

 it('should reject the Promise on failure', inject([AsyncTestCompleter], (async) => {
      PromiseWrapper.catchError(xhr.get(url404), (e) => {
        expect(e).toEqual(`Failed to load ${url404}`);
        async.done();
        return null;
      });
    }));
开发者ID:AsherBarak,项目名称:angular,代码行数:7,代码来源:xhr_impl_spec.ts

示例3: navigate

  /**
   * Navigate to a URL. Returns a promise that resolves to the canonical URL for the route.
   *
   * If the given URL begins with a `/`, router will navigate absolutely.
   * If the given URL does not begin with `/`, the router will navigate relative to this component.
   */
  navigate(url: string): Promise<any> {
    if (this.navigating) {
      return PromiseWrapper.resolve(true);
    }

    this.lastNavigationAttempt = url;

    var matchedInstruction = this.recognize(url);

    if (isBlank(matchedInstruction)) {
      return PromiseWrapper.resolve(false);
    }

    if (isPresent(this._currentInstruction)) {
      matchedInstruction.reuseComponentsFrom(this._currentInstruction);
    }

    this._startNavigating();

    var result = this.commit(matchedInstruction)
                     .then((_) => {
                       ObservableWrapper.callNext(this._subject, matchedInstruction.accumulatedUrl);
                       this._finishNavigating();
                     });

    PromiseWrapper.catchError(result, (_) => this._finishNavigating());

    return result;
  }
开发者ID:Mariem-07,项目名称:angular,代码行数:35,代码来源:router.ts

示例4: inject

 inject([AsyncTestCompleter], (async) => {
   PromiseWrapper.catchError(aggregate([], {captureFrames: true}), (err) => {
     expect(() => { throw err; })
         .toThrowError(
             'frame capture requested in benchpress, but no start event was found');
     async.done();
   });
 }));
开发者ID:Ashok-Pal,项目名称:angular,代码行数:8,代码来源:perflog_metric_spec.ts

示例5: expect

 .then((applicationRef) => {
   var router = applicationRef.hostComponent.router;
   PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => {
     expect(el).toHaveText('outer { oh no }');
     expect(error.message).toBe('oops!');
     async.done();
   });
 });
开发者ID:chenxiangdashen,项目名称:angular,代码行数:8,代码来源:router_integration_spec.ts

示例6: expect

 tcb.createAsync(AppCmp).then((rootTC) => {
   var router = rootTC.componentInstance.router;
   PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => {
     expect(rootTC.nativeElement).toHaveText('outer { oh no }');
     expect(error).toContainError('oops!');
     async.done();
   });
 });
开发者ID:goderbauer,项目名称:angular,代码行数:8,代码来源:router_integration_spec.ts

示例7: it

 it('should throw for non components', inject([AsyncTestCompleter], (async) => {
      PromiseWrapper.catchError(PromiseWrapper.wrap(() => compile([NonComponent])), (error) => {
        expect(error.message)
            .toEqual(
                `Could not compile '${stringify(NonComponent)}' because it is not a component.`);
        async.done();
      });
    }));
开发者ID:TedSander,项目名称:angular,代码行数:8,代码来源:template_compiler_spec.ts

示例8: it

 it('should throw if no end event', inject([AsyncTestCompleter], (async) => {
      PromiseWrapper.catchError(
          aggregate(
              [eventFactory.markStart('frameCapture', 3), eventFactory.instant('frame', 4)],
              {captureFrames: true}),
          (err) => {
            expect(() => { throw err; }).toThrowError('missing end event for frame capture');
            async.done();
          });
    }));
开发者ID:Ashok-Pal,项目名称:angular,代码行数:10,代码来源:perflog_metric_spec.ts

示例9: it

 it('should report loading errors', inject([AsyncTestCompleter], (async) => {
   var compiler = createCompiler(EMPTY_STEP, MapWrapper.create());
   PromiseWrapper.catchError(compiler.compile(new Template({
     componentId: 'someId',
     absUrl: 'someUrl'
   })), (e) => {
     expect(e.message).toContain(`Failed to load the template "someId"`);
     async.done();
   });
 }));
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:compiler_common_tests.ts


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