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


TypeScript stacktrace-js.fromError函数代码示例

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


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

示例1: error

export function error(error: Error) {
    StackTrace.fromError(error).then((stack) => {
        console.log(stack);
    }).catch((err) => {
        console.error(err);
    });

    let stack = ErrorStackParser.parse(error) || [];
    stack = stack.map((frame) => {
        return {
            filename: frame.fileName,
            abs_path: frame.fileName,
            lineno: frame.lineNumber,
            colno: frame.columnNumber,
            context_line: frame.functionName
        };
    }).reverse();

    let options = getOptions({
        level: LogLevel.Error,
        error: error,
        exception: [
            {
                type: error.name,
                value: error.message,
                stacktrace: {
                    frames: stack
                }
            }
        ]
    });

    return postData(options);
};
开发者ID:cime,项目名称:nativescript-raven,代码行数:34,代码来源:raven.ts

示例2:

    this.stackString = Observable.create(observer => {
      StackTrace.fromError(error)
        .then(stackframes => {
          let stackString: string = stackframes
            .splice(0, 20)
            .map(stackFrame => {
              return stackFrame.toString();
            })
            .join('\n');
          
          observer.next(stackString);
          observer.complete();

          let logMessage = {};
  
          logMessage['errorMessage'] = this.errorMessage, 
          logMessage['url'] = router.url,
          logMessage['stackTrace'] = stackString
  
          let http = this.injector.get(HttpClient);

          http.post('/api/writeLog', logMessage)
            .subscribe({
              error: error => {
                console.error('An error occurred calling api/writeLog:', error);
              }
            });
        });
    });
开发者ID:emmettos,项目名称:CarraigOgRegister,代码行数:29,代码来源:application-error-handler.service.ts

示例3: reportError

window.onerror = (msg, url, line, col, error) => {
    if (!error) {
        reportError(msg.toString(), "(stack not available)");
        return true;
    }
    // Make a preliminary report, which will be discarded if the stack conversion succeeds.
    reportPreliminaryError(msg.toString(), error.stack);
    // Try to make the report using source stack.
    StackTrace.fromError(error).then(stackframes => {
        var stringifiedStack = stackframes
            .map(sf => {
                return sf.toString();
            })
            .join("\n");
        reportError(msg.toString(), stringifiedStack);
    });
    return true; // suppress normal handling.
};
开发者ID:ermshiperete,项目名称:BloomDesktop,代码行数:18,代码来源:errorHandler.ts

示例4: handleError

  handleError(error) {
    const loggerService = this.injector.get(LoggerService);
    const location = this.injector.get(LocationStrategy);
    const url = location instanceof PathLocationStrategy ? location.path() : '';
    const message = error.message ? error.message : error.toString();

    // get the stack trace, lets grab the last 10 stacks only
    StackTrace.fromError(error).then(stackframes => {
      const stackString = stackframes
        .splice(0, 20)
        .map(function (sf) {
          return sf.toString();
        }).join('\n');

        loggerService.log('info', { message, url, stack: stackString });
    });    

    // IMPORTANT: Rethrow the error otherwise it gets swallowed
    throw error;
  }
开发者ID:GaetanCesaro,项目名称:ionicTest,代码行数:20,代码来源:error-handler.ts

示例5: handleError

    handleError(error) {
        const loggingService = this.injector.get(LoggingService);
        const location = this.injector.get(LocationStrategy);
        const message = error.message ? error.message : error.toString();

        const url = location instanceof PathLocationStrategy ? location.path() : '';

        // get the stack trace, lets grab the last 10 stacks only
        StackTrace.fromError(error).then(stackframes => {
            const stackString = stackframes
                .splice(0, 20)
                .map(function(sf) {
                    return sf.toString();
                }).join('\n');

            // log on the server
            loggingService.error({ message, url, stack: stackString });
        });

        throw error;
    }
开发者ID:guichafy,项目名称:angular5-starter,代码行数:21,代码来源:global-error.service.ts

示例6: handleError

    handleError(error) {
        if (Lib.DevMode()){
            throw error;
        }          

        // const loggingService = this.injector.get(LoggingService);
        // const location = this.injector.get(LocationStrategy);
        // const url = location instanceof PathLocationStrategy   ? location.path() : '';
        var message = error.message ? error.message : error.toString();
        var url = 'https://secure.digitalsignage.com/stacktrace/';

        // get the stack trace, lets grab the last 10 stacks only
        StackTrace.fromError(error).then(stackframes => {
            const stackString = stackframes
                .splice(0, 20)
                .map(function (sf) {
                    return sf.toString();
                }).join('\n');
            var date = moment().format('YYYY-MM-DD h:mm:ss');
            message = `error :: business :: ${window['business_id']} :: studiolite :: ${date} :: ${message}`
            StackTrace.report(stackString, url, message);
        });
        throw error;
    }
开发者ID:born2net,项目名称:signagestudio_web-lite,代码行数:24,代码来源:global-error-handler.ts


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