Skip to content

Commit

Permalink
Recognize internal fatal errors too
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Jul 2, 2024
1 parent 8dba596 commit 01bde73
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 14 deletions.
9 changes: 3 additions & 6 deletions lib/cli-errors.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/cli-errors.js.map

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

19 changes: 19 additions & 0 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.

13 changes: 7 additions & 6 deletions src/cli-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export class CommandInvocationError extends Error {
if (fatalErrors) {
message =
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode} and error was: ${fatalErrors.trim()} See the logs for more details.`;
`Exit code was ${exitCode} and error was: ${ensureEndsInPeriod(
fatalErrors.trim(),
)} See the logs for more details.`;
} else if (autobuildErrors) {
const autobuildHelpLink =
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed";
Expand All @@ -32,10 +34,9 @@ export class CommandInvocationError extends Error {
`For more information, see ${autobuildHelpLink}. ` +
`Encountered the following error: ${autobuildErrors}`;
} else {
let lastLine = stderr.trim().split("\n").pop()?.trim() || "";
if (lastLine[lastLine.length - 1] !== ".") {
lastLine += ".";
}
const lastLine = ensureEndsInPeriod(
stderr.trim().split("\n").pop()?.trim() || "n/a",
);
message =
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode} and last log line was: ${lastLine} See the logs for more details.`;
Expand Down Expand Up @@ -75,7 +76,7 @@ export class CommandInvocationError extends Error {
* the Actions UI.
*/
function extractFatalErrors(error: string): string | undefined {
const fatalErrorRegex = /.*fatal error occurred:/gi;
const fatalErrorRegex = /.*fatal (internal )?error occurr?ed(. Details)?:/gi;
let fatalErrors: string[] = [];
let lastFatalErrorIndex: number | undefined;
let match: RegExpMatchArray | null;
Expand Down
Loading

0 comments on commit 01bde73

Please sign in to comment.