Always include exit code in first line of CommandInvocationError

This commit is contained in:
Henry Mercer 2023-07-21 14:26:44 +01:00
parent a3ef0b984b
commit 2eb34f2fb9
3 changed files with 5 additions and 11 deletions

View file

@ -54,12 +54,9 @@ export class CommandInvocationError extends Error {
const prettyCommand = [cmd, ...args]
.map((x) => (x.includes(" ") ? `'${x}'` : x))
.join(" ");
error = error.trim();
const separator = error.includes("\n") ? "\n" : " ";
super(
`Encountered a fatal error while running "${prettyCommand}".${separator}` +
`Exit code was ${exitCode} and error was:${separator}` +
`${error}`
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode} and error was: ${error.trim()}`
);
}
}