當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。