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