Skip to content

Commit 0f871fa

Browse files
committed
Improve CommandInvocationError message
1 parent c844189 commit 0f871fa

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

lib/codeql.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeql.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,11 +1185,12 @@ test("database finalize does not override no code found error on CodeQL 2.12.4",
11851185
sinon.stub(safeWhich, "safeWhich").resolves("");
11861186

11871187
await t.throwsAsync(
1188-
async () => await codeqlObject.finalizeDatabase("", "", ""),
1188+
async () =>
1189+
await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"),
11891190
{
11901191
message:
1191-
"Failure invoking codeql-for-testing with arguments database,finalize,--finalize-dataset,,,.\n" +
1192-
`Exit code 32 and error was:\n${cliMessage}`,
1192+
'Encountered a fatal error while running "codeql-for-testing database finalize --finalize-dataset --threads=2 --ram=2048 db".\n' +
1193+
`Exit code was 32 and error was:\n${cliMessage}`,
11931194
}
11941195
);
11951196
});

src/codeql.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ export class CommandInvocationError extends Error {
5151
public error: string,
5252
public output: string
5353
) {
54+
const prettyCommand = [cmd, ...args]
55+
.map((x) => (x.includes(" ") ? `'${x}'` : x))
56+
.join(" ");
5457
super(
55-
`Failure invoking ${cmd} with arguments ${args}.\n` +
56-
`Exit code ${exitCode} and error was:\n` +
58+
`Encountered a fatal error while running "${prettyCommand}".\n` +
59+
`Exit code was ${exitCode} and error was:\n` +
5760
`${error}`
5861
);
5962
}

0 commit comments

Comments
 (0)