Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve CommandInvocationError message
  • Loading branch information
henrymercer committed Jul 21, 2023
commit 0f871fa80d78cdcd2c71a3a370fc9f03c7874fb5
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