MCPcopy Index your code
hub / github.com/nodejs/node / reconstructErrorStack

Function reconstructErrorStack

lib/internal/modules/cjs/loader.js:1989–2000  ·  view source on GitHub ↗
(err, parentPath, parentSource)

Source from the content-addressed store, hash-verified

1987}
1988
1989function reconstructErrorStack(err, parentPath, parentSource) {
1990 const errLine = StringPrototypeSplit(
1991 StringPrototypeSlice(err.stack, StringPrototypeIndexOf(
1992 err.stack, ' at ')), '\n', 1)[0];
1993 const { 1: line, 2: col } =
1994 RegExpPrototypeExec(/(\d+):(\d+)\)/, errLine) || [];
1995 if (line && col) {
1996 const srcLine = StringPrototypeSplit(parentSource, '\n', line)[line - 1];
1997 const frame = `${parentPath}:${line}\n${srcLine}\n${StringPrototypeRepeat(' ', col - 1)}^\n`;
1998 setArrowMessage(err, frame);
1999 }
2000}
2001
2002/**
2003 * Generate the legacy ERR_REQUIRE_ESM for the cases where require(esm) is disabled.

Callers 1

getRequireESMErrorFunction · 0.85

Calls 1

setArrowMessageFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…