How to use stacktrace-parser - 8 common examples

To help you get started, we’ve selected a few stacktrace-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maty21 / mocha-sidebar / lib / provider-extensions / decorationProvider.js View on Github external
setDecoration(status, test) {
    if (config.sideBarOptions().decoration) {
      let style = this.getStyle(status);
      //    console.log(`test file in decorations: ${test.item.__test.file}, name:${test.item.__test.name}`);
      if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.fileName == test.file) {
        let decorators = {
          range: new vscode.Range(test.meta.number - 1, 0, test.meta.number - 1, 1e3),
          hoverMessage: new vscode.MarkdownString("#### " + status)
          //range: new vscode.Range(line[0].number - 1, it.start.column - 1,  line[0].number - 1, it.start.column + 1)
        };
        try {
          //stub
          if (status == consts.FAILED) {
            const stacktrace = stacktraceParser.parse(test.error.raw.stack);
            if (stacktrace && stacktrace[0] && stacktrace[0].lineNumber) {
              let errorMessageDecorator = {
                range: new vscode.Range(stacktrace[0].lineNumber - 1, 0, stacktrace[0].lineNumber - 1, 1e3),
                hoverMessage: new vscode.MarkdownString(`#### Stack trace
\`\`\`javascript 
        ${test.error.raw.stack}


        
    \`\`\` `)
              };
              let errorMessageStyle = decorationType.expectErrorMessage(test.error.raw.message);
              this.pushStyle.push(errorMessageStyle);
              vscode.window.activeTextEditor.setDecorations(errorMessageStyle, [errorMessageDecorator]);
            }
          }
github MeasureOSS / Measure / lib / nice_errors.js View on Github external
function renderStack(e) {
    var st = StackTraceParser.parse(e.stack)[0];
    var parts = __dirname.split("/");
    var parent = parts.slice(0, parts.length-1).join("/")
    var fn = st.file.replace(parent + "/", "");
    return `${e.message}, ${fn}:${st.lineNumber}`;
}
const NICE_ERRORS = {
github audiojs / audio-generator / element.js View on Github external
this.stream.on('generror', function (e) {
		//find the line of a code
		var stack = parseStack(e.stack);

		var evalOffset = 2;

		var message = e.message + ' at ' + (stack[0].lineNumber - evalOffset) + ':' + stack[0].column;

		error.value = message;
	});
github learn-co / learn-ide / lib / airbrake.js View on Github external
backtrace(stack='') {
    return parse(stack).map((entry) => {
      return {
        file: entry.file,
        line: entry.lineNumber,
        column: entry.column,
        function: entry.methodName
      };
    });
  },
github fgnass / retrace / index.js View on Github external
Retrace.prototype.map = function(stack) {
  return Promise.all(parser.parse(stack).map(this.mapFrame, this))
  .then(function(frames) {
    var msg = /^.*$/m.exec(stack)[0];
    return msg + '\n' + frames.map(function(f) {
      var pos = f.source;
      if (f.line) pos += ':' + f.line;
      if (f.column >= 0) pos += ':' + f.column;
      var loc = f.name ? f.name + '(' + pos + ')' : pos;
      return '    at ' + loc;
    }).join('\n');
  });
};
github avetjs / avet / packages / avet-build / lib / server / index.js View on Github external
function parseErrorStack(e) {
  if (!e || !e.stack) {
    return [];
  }

  const stacktraceParser = require('stacktrace-parser');
  const stack = Array.isArray(e.stack)
    ? e.stack
    : stacktraceParser.parse(e.stack);

  let framesToPop = typeof e.framesToPop === 'number' ? e.framesToPop : 0;
  while (framesToPop--) {
    stack.shift();
  }
  return stack;
}
github olofd / react-native-device-log / debug-service.js View on Github external
const parseErrorStack = error => {
                    if (!error || !error.stack) {
                        return [];
                    }
                    return Array.isArray(error.stack)
                        ? error.stack
                        : stacktraceParser.parse(error.stack);
                };
github kaspernj / api_maker / lib / api_maker / javascript / source-maps-loader.js View on Github external
getStackTraceData(stackTrace) {
    const stack = stackTraceParser.parse(stackTrace)
    const newSourceMap = []

    for(const trace of stack) {
      const sourceMapData = this.sourceMaps.find((sourceMapData) => sourceMapData.originalUrl == trace.file)
      let filePath, fileString, original

      if (sourceMapData) {
        const sourceMapConsumer = sourceMapData.consumer
        original = sourceMapConsumer.originalPositionFor({
          line: trace.lineNumber,
          column: trace.column
        })
      }

      if (original && original.source) {
        filePath = original.source.replace(/^webpack:\/\/\//, "")

stacktrace-parser

Parses every stack trace into a nicely formatted array of hashes.

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis

Popular stacktrace-parser functions