Add catch-all error reporting for errors that slip through run

This commit is contained in:
Henry Mercer
2026-01-22 13:14:53 +00:00
parent 14bd76753f
commit 229e0cd749
17 changed files with 447 additions and 101 deletions
+18 -2
View File
@@ -28,6 +28,7 @@ import { getRepositoryNwo } from "./repository";
import {
StatusReportBase,
sendStatusReport,
sendUnexpectedErrorStatusReport,
createStatusReportBase,
getActionsStatus,
ActionName,
@@ -41,12 +42,11 @@ interface InitPostStatusReport
initActionPostHelper.JobStatusReport,
initActionPostHelper.DependencyCachingUsageReport {}
async function runWrapper() {
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 logger = getActionsLogger();
const startedAt = new Date();
let config: Config | undefined;
let uploadFailedSarifResult:
| initActionPostHelper.UploadFailedSarifResult
@@ -139,4 +139,20 @@ async function runWrapper() {
}
}
async function runWrapper() {
const startedAt = new Date();
const logger = getActionsLogger();
try {
await run(startedAt);
} catch (error) {
core.setFailed(`init post action failed: ${wrapError(error).message}`);
await sendUnexpectedErrorStatusReport(
ActionName.InitPost,
startedAt,
error,
logger,
);
}
}
void runWrapper();