Skip to content

Commit 01bde73

Browse files
committed
Recognize internal fatal errors too
1 parent 8dba596 commit 01bde73

File tree

6 files changed

+56
-14
lines changed

6 files changed

+56
-14
lines changed

lib/cli-errors.js

+3-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/cli-errors.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli-errors.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export class CommandInvocationError extends Error {
2323
if (fatalErrors) {
2424
message =
2525
`Encountered a fatal error while running "${prettyCommand}". ` +
26-
`Exit code was ${exitCode} and error was: ${fatalErrors.trim()} See the logs for more details.`;
26+
`Exit code was ${exitCode} and error was: ${ensureEndsInPeriod(
27+
fatalErrors.trim(),
28+
)} See the logs for more details.`;
2729
} else if (autobuildErrors) {
2830
const autobuildHelpLink =
2931
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed";
@@ -32,10 +34,9 @@ export class CommandInvocationError extends Error {
3234
`For more information, see ${autobuildHelpLink}. ` +
3335
`Encountered the following error: ${autobuildErrors}`;
3436
} else {
35-
let lastLine = stderr.trim().split("\n").pop()?.trim() || "";
36-
if (lastLine[lastLine.length - 1] !== ".") {
37-
lastLine += ".";
38-
}
37+
const lastLine = ensureEndsInPeriod(
38+
stderr.trim().split("\n").pop()?.trim() || "n/a",
39+
);
3940
message =
4041
`Encountered a fatal error while running "${prettyCommand}". ` +
4142
`Exit code was ${exitCode} and last log line was: ${lastLine} See the logs for more details.`;
@@ -75,7 +76,7 @@ export class CommandInvocationError extends Error {
7576
* the Actions UI.
7677
*/
7778
function extractFatalErrors(error: string): string | undefined {
78-
const fatalErrorRegex = /.*fatal error occurred:/gi;
79+
const fatalErrorRegex = /.*fatal (internal )?error occurr?ed(. Details)?:/gi;
7980
let fatalErrors: string[] = [];
8081
let lastFatalErrorIndex: number | undefined;
8182
let match: RegExpMatchArray | null;

0 commit comments

Comments
 (0)