MCPcopy Create free account
hub / github.com/sindresorhus/execa / getErrorPrefix

Function getErrorPrefix

lib/return/message.js:64–121  ·  view source on GitHub ↗
({
	originalError,
	timedOut,
	timeout,
	isMaxBuffer,
	maxBuffer,
	errorCode,
	signal,
	signalDescription,
	exitCode,
	isCanceled,
	isGracefullyCanceled,
	isForcefullyTerminated,
	forceKillAfterDelay,
	killSignal,
})

Source from the content-addressed store, hash-verified

62};
63
64const getErrorPrefix = ({
65 originalError,
66 timedOut,
67 timeout,
68 isMaxBuffer,
69 maxBuffer,
70 errorCode,
71 signal,
72 signalDescription,
73 exitCode,
74 isCanceled,
75 isGracefullyCanceled,
76 isForcefullyTerminated,
77 forceKillAfterDelay,
78 killSignal,
79}) => {
80 const forcefulSuffix = getForcefulSuffix(isForcefullyTerminated, forceKillAfterDelay);
81
82 if (timedOut) {
83 return `Command timed out after ${timeout} milliseconds${forcefulSuffix}`;
84 }
85
86 if (isGracefullyCanceled) {
87 if (signal === undefined) {
88 return `Command was gracefully canceled with exit code ${exitCode}`;
89 }
90
91 return isForcefullyTerminated
92 ? `Command was gracefully canceled${forcefulSuffix}`
93 : `Command was gracefully canceled with ${signal} (${signalDescription})`;
94 }
95
96 if (isCanceled) {
97 return `Command was canceled${forcefulSuffix}`;
98 }
99
100 if (isMaxBuffer) {
101 return `${getMaxBufferMessage(originalError, maxBuffer)}${forcefulSuffix}`;
102 }
103
104 if (errorCode !== undefined) {
105 return `Command failed with ${errorCode}${forcefulSuffix}`;
106 }
107
108 if (isForcefullyTerminated) {
109 return `Command was killed with ${killSignal} (${getSignalDescription(killSignal)})${forcefulSuffix}`;
110 }
111
112 if (signal !== undefined) {
113 return `Command was killed with ${signal} (${signalDescription})`;
114 }
115
116 if (exitCode !== undefined) {
117 return `Command failed with exit code ${exitCode}`;
118 }
119
120 return 'Command failed';
121};

Callers 1

createMessagesFunction · 0.85

Calls 3

getMaxBufferMessageFunction · 0.90
getSignalDescriptionFunction · 0.90
getForcefulSuffixFunction · 0.85

Tested by

no test coverage detected