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


TypeScript errors.getDebugContext函数代码示例

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


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

示例1: it

      it('should report debug info on binding errors', () => {
        class QueryService {
          set a(value: any) { throw new Error('Test'); }
        }

        const {view} = createAndGetRootNodes(compViewDef([
          elementDef(NodeFlags.None, null, null, 3, 'div'),
          directiveDef(NodeFlags.None, null, 1, QueryService, []),
          queryDef(
              NodeFlags.TypeContentQuery | NodeFlags.DynamicQuery, someQueryId,
              {'a': QueryBindingType.All}),
          aServiceProvider(),
        ]));


        let err: any;
        try {
          Services.checkAndUpdateView(view);
        } catch (e) {
          err = e;
        }
        expect(err).toBeTruthy();
        expect(err.message).toBe('Test');
        const debugCtx = getDebugContext(err);
        expect(debugCtx.view).toBe(view);
        expect(debugCtx.nodeIndex).toBe(2);
      });
开发者ID:ballipongala,项目名称:angular,代码行数:27,代码来源:query_spec.ts

示例2: it

      it('should checkNoChanges', () => {
        const {view} = createAndGetRootNodes(compViewDef([
          elementDef(NodeFlags.None, null, null, 3, 'div'),
          ...contentQueryProviders(),
          anchorDef(NodeFlags.HasEmbeddedViews, null, null, 0, embeddedViewDef([
                      elementDef(NodeFlags.None, null, null, 1, 'div'),
                      aServiceProvider(),
                    ])),
        ]));

        Services.checkAndUpdateView(view);
        Services.checkNoChangesView(view);

        const childView = Services.createEmbeddedView(view, view.def.nodes[3]);
        attachEmbeddedView(asElementData(view, 3), 0, childView);

        let err: any;
        try {
          Services.checkNoChangesView(view);
        } catch (e) {
          err = e;
        }
        expect(err).toBeTruthy();
        expect(err.message)
            .toBe(
                `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'Query 1 not dirty'. Current value: 'Query 1 dirty'.`);
        const debugCtx = getDebugContext(err);
        expect(debugCtx.view).toBe(view);
        expect(debugCtx.nodeIndex).toBe(2);
      });
开发者ID:tolemac,项目名称:angular,代码行数:30,代码来源:query_spec.ts

示例3: it

        it('should report debug info on event errors', () => {
          const handleErrorSpy = spyOn(TestBed.get(ErrorHandler), 'handleError');
          const addListenerSpy = spyOn(HTMLElement.prototype, addEventListener).and.callThrough();
          const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
              0, NodeFlags.None, null, null, 0, 'button', null, null, [[null !, 'click']],
              () => { throw new Error('Test'); })]));

          callMostRecentEventListenerHandler(addListenerSpy, 'SomeEvent');
          const err = handleErrorSpy.calls.mostRecent().args[0];
          expect(err).toBeTruthy();
          expect(err.message).toBe('Test');
          const debugCtx = getDebugContext(err);
          expect(debugCtx.view).toBe(view);
          expect(debugCtx.nodeIndex).toBe(0);
        });
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:15,代码来源:element_spec.ts

示例4: it

        it('should report debug info on event errors', () => {
          const addListenerSpy = spyOn(HTMLElement.prototype, 'addEventListener').and.callThrough();
          const {view, rootNodes} = createAndAttachAndGetRootNodes(compViewDef([elementDef(
              NodeFlags.None, null, null, 0, 'button', null, null, [[null, 'click']],
              () => { throw new Error('Test'); })]));

          let err: any;
          try {
            addListenerSpy.calls.mostRecent().args[1]('SomeEvent');
          } catch (e) {
            err = e;
          }
          expect(err).toBeTruthy();
          expect(err.message).toBe('Test');
          const debugCtx = getDebugContext(err);
          expect(debugCtx.view).toBe(view);
          expect(debugCtx.nodeIndex).toBe(0);
        });
开发者ID:rlugojr,项目名称:angular,代码行数:18,代码来源:element_spec.ts


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