Add reminder to minimise code outside try/catch

This commit is contained in:
Henry Mercer
2026-01-22 11:31:17 +00:00
parent b715292b74
commit 14bd76753f
11 changed files with 33 additions and 0 deletions

View File

@@ -21,6 +21,9 @@ import { getActionsLogger } from "./logging";
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
async function runWrapper() {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
try {
actionsUtil.restoreInputs();
const logger = getActionsLogger();

View File

@@ -209,6 +209,9 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) {
}
async function run() {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
const startedAt = new Date();
let uploadResults:
| Partial<Record<analyses.AnalysisKind, UploadResult>>

View File

@@ -69,6 +69,9 @@ async function sendCompletedStatusReport(
}
async function run() {
// 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 config: Config | undefined;

View File

@@ -42,6 +42,9 @@ interface InitPostStatusReport
initActionPostHelper.DependencyCachingUsageReport {}
async function runWrapper() {
// 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;

View File

@@ -192,6 +192,9 @@ async function sendCompletedStatusReport(
}
async function run() {
// 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();

View File

@@ -30,6 +30,9 @@ import {
const ENVIRONMENT_OUTPUT_NAME = "environment";
async function run() {
// 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();

View File

@@ -86,6 +86,9 @@ async function sendCompletedStatusReport(
/** The main behaviour of this action. */
async function run(): Promise<void> {
// 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();

View File

@@ -13,6 +13,9 @@ import { getActionsLogger } from "./logging";
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
async function runWrapper() {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
const logger = getActionsLogger();
try {

View File

@@ -123,6 +123,9 @@ async function sendSuccessStatusReport(
}
async function runWrapper() {
// 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();

View File

@@ -13,6 +13,9 @@ import { getActionsLogger, withGroup } from "./logging";
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
async function runWrapper() {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
try {
// Restore inputs from `upload-sarif` Action.
actionsUtil.restoreInputs();

View File

@@ -54,6 +54,9 @@ async function sendSuccessStatusReport(
}
async function run() {
// 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();