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

Function getPrintedStackTrace

test/abort/test-abort-backtrace.js:6–43  ·  view source on GitHub ↗
(stderr)

Source from the content-addressed store, hash-verified

4const cp = require('child_process');
5
6function getPrintedStackTrace(stderr) {
7 const lines = stderr.split('\n');
8
9 let state = 'initial';
10 const result = {
11 message: [],
12 nativeStack: [],
13 jsStack: [],
14 };
15 for (let i = 0; i < lines.length; ++i) {
16 const line = lines[i].trim();
17 if (line.length === 0) {
18 continue; // Skip empty lines.
19 }
20
21 switch (state) {
22 case 'initial':
23 result.message.push(line);
24 if (line.includes('Native stack trace')) {
25 state = 'native-stack';
26 } else {
27 result.message.push(line);
28 }
29 break;
30 case 'native-stack':
31 if (line.includes('JavaScript stack trace')) {
32 state = 'js-stack';
33 } else {
34 result.nativeStack.push(line);
35 }
36 break;
37 case 'js-stack':
38 result.jsStack.push(line);
39 break;
40 }
41 }
42 return result;
43}
44
45if (process.argv[2] === 'child') {
46 process.abort();

Callers 1

Calls 3

includesMethod · 0.80
splitMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…