Skip to content

Commit

Permalink
Improve CommandInvocationError message
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Jul 21, 2023
1 parent c844189 commit 0f871fa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
7 changes: 5 additions & 2 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1185,11 +1185,12 @@ test("database finalize does not override no code found error on CodeQL 2.12.4",
sinon.stub(safeWhich, "safeWhich").resolves("");

await t.throwsAsync(
async () => await codeqlObject.finalizeDatabase("", "", ""),
async () =>
await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"),
{
message:
"Failure invoking codeql-for-testing with arguments database,finalize,--finalize-dataset,,,.\n" +
`Exit code 32 and error was:\n${cliMessage}`,
'Encountered a fatal error while running "codeql-for-testing database finalize --finalize-dataset --threads=2 --ram=2048 db".\n' +
`Exit code was 32 and error was:\n${cliMessage}`,
}
);
});
Expand Down
7 changes: 5 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ export class CommandInvocationError extends Error {
public error: string,
public output: string
) {
const prettyCommand = [cmd, ...args]
.map((x) => (x.includes(" ") ? `'${x}'` : x))
.join(" ");
super(
`Failure invoking ${cmd} with arguments ${args}.\n` +
`Exit code ${exitCode} and error was:\n` +
`Encountered a fatal error while running "${prettyCommand}".\n` +
`Exit code was ${exitCode} and error was:\n` +
`${error}`
);
}
Expand Down

0 comments on commit 0f871fa

Please sign in to comment.