How to use the error-stack-parser.extractLocation 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 iodide-project / iodide / src / reps / serialization / get-error-stack-summary.js View on Github external
lineNumber: evalLocationParts[1],
          columnNumber: evalLocationParts[2],
          source: line,
          isEval: true
        });
      }
    }

    if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
      // Safari eval frames only have function names and nothing else
      return new StackFrame({
        functionName: line
      });
    }

    const locationParts = ErrorStackParser.extractLocation(
      line.replace(functionNameRegex, "")
    );

    return new StackFrame({
      functionName,
      fileName: locationParts[0],
      lineNumber: locationParts[1],
      columnNumber: locationParts[2],
      source: line
    });
  }, ErrorStackParser);
};
github iodide-project / iodide / src / reps / serialization / get-error-stack-summary.js View on Github external
return filtered.map(line => {
    const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
    const matches = line.match(functionNameRegex);
    const functionName = matches && matches[1] ? matches[1] : undefined;

    if (line.indexOf(" > eval") > -1) {
      const regExp = / > (eval:\d+:\d+)$/;
      const evalParts = regExp.exec(line);
      if (evalParts) {
        const evalLocationParts = ErrorStackParser.extractLocation(
          evalParts[1]
        );
        return new StackFrame({
          functionName: functionName !== undefined ? functionName : "eval",
          fileName: "cell",
          lineNumber: evalLocationParts[1],
          columnNumber: evalLocationParts[2],
          source: line,
          isEval: true
        });
      }
    }

    if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
      // Safari eval frames only have function names and nothing else
      return new StackFrame({
github iodide-project / iodide / src / reps / serialization / get-error-stack-summary.js View on Github external
if (evalParts) {
        const evalLocationParts = ErrorStackParser.extractLocation(
          evalParts[1]
        );
        return new StackFrame({
          functionName: tokens[0],
          fileName: "cell",
          lineNumber: evalLocationParts[1],
          columnNumber: evalLocationParts[2],
          source: line,
          isEval: true
        });
      }
    }

    const locationParts = ErrorStackParser.extractLocation(tokens.pop());
    const functionName = tokens.join(" ") || undefined;
    const fileName =
      ["eval", ""].indexOf(locationParts[0]) > -1
        ? undefined
        : locationParts[0];

    return new StackFrame({
      functionName,
      fileName,
      lineNumber: locationParts[1],
      columnNumber: locationParts[2],
      source: line
    });
  }, ErrorStackParser);
};

error-stack-parser

Extract meaning from JS Errors

MIT
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis