MCPcopy
hub / github.com/meteor/meteor / parse

Function parse

tools/utils/parse-stack.js:17–57  ·  view source on GitHub ↗
(err)

Source from the content-addressed store, hash-verified

15// return anything past that function. We call this the "user portion"
16// of the stack.
17export function parse(err) {
18 const stack = err.stack;
19 if (typeof stack !== "string") {
20 return {};
21 }
22
23 // at least the first line is the exception
24 const frames = stack.split("\n").slice(1)
25 // longjohn adds lines of the form '---' (45 times) to separate
26 // the trace across async boundaries. It's not clear if we need to
27 // separate the trace in the same way we do for future boundaries below
28 // (it's not clear that that code is still useful either)
29 // so for now, we'll just remove such lines
30 .filter(f => ! f.match(/^\-{45}$/));
31
32 // " - - - - -"
33 // This is something added when you throw an Error through a Future. The
34 // stack above the dashes is the stack of the 'wait' call; the stack below
35 // is the stack inside the fiber where the Error is originally
36 // constructed.
37 // XXX This code assumes that the stack trace can only be split once. It's not
38 // clear whether this can happen multiple times.
39 const indexOfFiberSplit = frames.indexOf(' - - - - -');
40
41 if (indexOfFiberSplit === -1) {
42 // This is a normal stack trace, not a split fiber stack trace
43 return {
44 outsideFiber: parseStackFrames(frames)
45 }
46 }
47
48 // If this is a split stack trace from a future, parse the frames above and
49 // below the split separately.
50 const outsideFiber = parseStackFrames(frames);
51 const insideFiber = parseStackFrames(frames.slice(indexOfFiberSplit + 1));
52
53 return {
54 insideFiber,
55 outsideFiber
56 };
57}
58
59// Decorator. Mark the point at which a stack trace returned by
60// parse() should stop: no frames earlier than this point will be

Callers 3

tryToParseFunction · 0.50
versionsAreCompatibleFunction · 0.50
runJavaScriptFunction · 0.50

Calls 3

parseStackFramesFunction · 0.85
indexOfMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…