mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 09:18:47 +00:00
Add catch-all error reporting for errors that slip through run
This commit is contained in:
+11
-3
@@ -64,6 +64,7 @@ import {
|
||||
createStatusReportBase,
|
||||
getActionsStatus,
|
||||
sendStatusReport,
|
||||
sendUnexpectedErrorStatusReport,
|
||||
} from "./status-report";
|
||||
import { ZstdAvailability } from "./tar";
|
||||
import { ToolsDownloadStatusReport } from "./tools-download";
|
||||
@@ -191,11 +192,10 @@ async function sendCompletedStatusReport(
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
async function run(startedAt: Date) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
|
||||
const startedAt = new Date();
|
||||
const logger = getActionsLogger();
|
||||
|
||||
let apiDetails: GitHubApiCombinedDetails;
|
||||
@@ -805,10 +805,18 @@ async function recordZstdAvailability(
|
||||
}
|
||||
|
||||
async function runWrapper() {
|
||||
const startedAt = new Date();
|
||||
const logger = getActionsLogger();
|
||||
try {
|
||||
await run();
|
||||
await run(startedAt);
|
||||
} catch (error) {
|
||||
core.setFailed(`init action failed: ${getErrorMessage(error)}`);
|
||||
await sendUnexpectedErrorStatusReport(
|
||||
ActionName.Init,
|
||||
startedAt,
|
||||
error,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
await checkForTimeout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user