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

Function logAndThrow

test/common/child_process.js:80–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 }
79
80 function logAndThrow() {
81 const tag = `[process ${child.pid}]:`;
82 console.error(`${tag} --- stderr ---`);
83 console.error(stderrStr === undefined ? child.stderr.toString() : stderrStr);
84 console.error(`${tag} --- stdout ---`);
85 console.error(stdoutStr === undefined ? child.stdout.toString() : stdoutStr);
86 console.error(`${tag} status = ${child.status}, signal = ${child.signal}`);
87
88 const error = new Error(`${failures.join('\n')}`);
89 if (typeof spawnArgs[2] === 'object' && spawnArgs[2] !== null) {
90 const envInOptions = spawnArgs[2].env;
91 // If the env is overridden in the spawn options, include it in the error
92 // object for easier debugging.
93 if (typeof envInOptions === 'object' && envInOptions !== null && envInOptions !== process.env) {
94 // Only include the environment variables that are different from
95 // the current process.env to avoid cluttering the output.
96 error.options = { ...spawnArgs[2], env: {} };
97 for (const key of Object.keys(envInOptions)) {
98 if (envInOptions[key] !== process.env[key]) {
99 error.options.env[key] = spawnArgs[2].env[key];
100 }
101 }
102 } else {
103 error.options = spawnArgs[2];
104 }
105 }
106 let command = spawnArgs[0];
107 if (Array.isArray(spawnArgs[1])) {
108 command += ' ' + spawnArgs[1].join(' ');
109 }
110 error.command = command;
111 Error.captureStackTrace(error, caller);
112 throw error;
113 }
114
115 // If status and signal are not matching expectations, fail early.
116 if (failures.length !== 0) {

Callers 1

expectSyncExitFunction · 0.85

Calls 4

keysMethod · 0.65
errorMethod · 0.45
toStringMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…