How to use the error-stack-parser.parse function in error-stack-parser

To help you get started, we’ve selected a few error-stack-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 DevExpress / testcafe / test / server / helpers / assert-runtime-error.js View on Github external
function assertStack (err, expected) {
    // HACK: stackParser can't handle empty stacks correctly
    // (it treats error messages as stack frames).
    // Therefore we add this dummy stack frame to make things work
    if (!expected.stackTop)
        err.stack += '\n    at (:1:1)';

    const parsedStack = stackParser.parse(err);

    if (expected.stackTop) {
        const expectedStackTop = Array.isArray(expected.stackTop) ? expected.stackTop : [expected.stackTop];

        parsedStack.forEach(function (frame, idx) {
            const filename   = frame.fileName;
            const isInternal = frame.fileName.indexOf('internal/') === 0 ||
                               frame.fileName.indexOf(sep) < 0;

            // NOTE: assert that stack is clean from internals
            expect(isInternal).to.be.false;
            expect(filename).not.to.contain(sep + 'babel-');
            expect(filename).not.to.contain(sep + 'babylon' + sep);
            expect(filename).not.to.contain(sep + 'core-js' + sep);

            if (expectedStackTop[idx])
github iodide-project / iodide / src / reps / serialization / get-error-stack-summary.js View on Github external
export function getErrorStackString(e) {
  // Handle passing in an Array of pre-parsed frames for testing
  const frames = e instanceof Array ? e : ErrorStackParser.parse(e);
  const outputFrames = [];

  for (const frame of frames) {
    if (frame.fileName !== undefined) {
      const parts = frame.fileName.split("/");
      if (parts[parts.length - 1].startsWith("iodide.eval-frame")) {
        break;
      }
    }
    outputFrames.push(frame.toString());
  }

  return `${e.name}: ${e.message}\n${outputFrames.join("\n")}`;
}
github recca0120 / tester-phpunit / lib / mocha-runner.js View on Github external
const pushTestResult = function pushTestResult(test) {
      console.log('++++pushTestResult', test);
      console.log('++++pushTestResult _trace', test._trace);
      if (!test || !test._trace) {
        console.log('++++test trace is empty', test);
        return;
      }
      const traceObjects = ErrorStackParser.parse(test._trace)
        .filter(stackTraceObject => stackTraceObject.fileName === outputFilePath);
      console.log('++++traceObjects', traceObjects);
      const traceObject = traceObjects.length > 0 ? traceObjects[0] : traceObjects;
      if (!traceObject) {
        console.log('++++traceObject is empty', test);
        return;
      }

      console.log('++++trace', traceObject);
      if (!test.state) {
        test.state = 'skipped';
      }
      messages.push({
        state: test.state,
        title: test.title,
        error: test.err,
github invertase / react-native-firebase / tests-new / bridge / env / node / source-map.js View on Github external
function sourceMappedError(error) {
  const original = error.stack.split('\n');
  const parsed = ErrorStack.parse(error);

  const newStack = [original[0]];

  for (let i = 0; i < parsed.length; i++) {
    const { fileName } = parsed[i];
    if (fileName === bundleFileName) newStack.push(frameToStr(parsed[i]));
    else newStack.push(original[i + 1]);
  }

  error.stack = newStack.join('\n');
  return error;
}
github aulizko / delicate-error-reporter / src / index.js View on Github external
renderFrames() {
    console.log('error', this.props.error);
    console.log('parsed error', ErrorStackParser.parse(this.props.error));
    return ErrorStackParser.parse(this.props.error).map((f) => {
      const link = `${ f.fileName }:${ f.lineNumber }:${ f.columnNumber }`;

      return (
        <div>
          <div>{ f.functionName }</div>
          <div>
            <a href="{">{ link }</a>
          </div>
        </div>
      );
    });
  }
github thealjey / webcompiler / src / logger.js View on Github external
export function logError(error: Error) {
  const {name, message, stack} = error;

  log(formatErrorMarker(name), ': ', message);

  error.stack = cleanStack(stack);

  forEach(ErrorStackParser.parse(error), ({functionName = 'unknown', fileName, lineNumber, columnNumber}) => {
    log('  • ', ...formatLine(functionName, fileName, lineNumber, columnNumber));
  });
}
github facebook / react / packages / react-debug-tools / src / ReactDebugHooks.js View on Github external
Dispatcher.useState(null);
      Dispatcher.useReducer((s, a) =&gt; s, null);
      Dispatcher.useRef(null);
      Dispatcher.useLayoutEffect(() =&gt; {});
      Dispatcher.useEffect(() =&gt; {});
      Dispatcher.useImperativeHandle(undefined, () =&gt; null);
      Dispatcher.useDebugValue(null);
      Dispatcher.useCallback(() =&gt; {});
      Dispatcher.useMemo(() =&gt; null);
    } finally {
      readHookLog = hookLog;
      hookLog = [];
    }
    for (let i = 0; i &lt; readHookLog.length; i++) {
      let hook = readHookLog[i];
      cache.set(hook.primitive, ErrorStackParser.parse(hook.stackError));
    }
    primitiveStackCache = cache;
  }
  return primitiveStackCache;
}
github facebook / react / packages / react-debug-tools / src / ReactDebugHooks.js View on Github external
ref: Ref,
  currentDispatcher: CurrentDispatcherRef,
): HooksTree {
  let previousDispatcher = currentDispatcher.current;
  let readHookLog;
  currentDispatcher.current = Dispatcher;
  let ancestorStackError;
  try {
    ancestorStackError = new Error();
    renderFunction(props, ref);
  } finally {
    readHookLog = hookLog;
    hookLog = [];
    currentDispatcher.current = previousDispatcher;
  }
  let rootStack = ErrorStackParser.parse(ancestorStackError);
  return buildTree(rootStack, readHookLog);
}
github elastic / apm-agent-js-core / src / error-logging / stack-trace-service.js View on Github external
createStackTraces (errorEvent) {
    var stackTraceService = this
    var error = errorEvent.error

    var stackTraces
    if (error) {
      try {
        stackTraces = errorStackParser.parse(error)
      } catch (e) {
        this._loggingService.debug('Parsing error stack failed!', e)
      }
    }

    if (!stackTraces || stackTraces.length === 0) {
      stackTraces = [
        {
          fileName: errorEvent.filename,
          lineNumber: errorEvent.lineno,
          columnNumber: errorEvent.colno
        }
      ]
    }

    stackTraces = ErrorStackNormalizer(stackTraces)

error-stack-parser

Extract meaning from JS Errors

MIT
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis