Skip to content

Commit 14bd767

Browse files
committed
Add reminder to minimise code outside try/catch
1 parent b715292 commit 14bd767

11 files changed

+33
-0
lines changed

src/analyze-action-post.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import { getActionsLogger } from "./logging";
2121
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
2222

2323
async function runWrapper() {
24+
// To capture errors appropriately, keep as much code within the try-catch as
25+
// possible, and only use safe functions outside.
26+
2427
try {
2528
actionsUtil.restoreInputs();
2629
const logger = getActionsLogger();

src/analyze-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) {
209209
}
210210

211211
async function run() {
212+
// To capture errors appropriately, keep as much code within the try-catch as
213+
// possible, and only use safe functions outside.
214+
212215
const startedAt = new Date();
213216
let uploadResults:
214217
| Partial<Record<analyses.AnalysisKind, UploadResult>>

src/autobuild-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ async function sendCompletedStatusReport(
6969
}
7070

7171
async function run() {
72+
// To capture errors appropriately, keep as much code within the try-catch as
73+
// possible, and only use safe functions outside.
74+
7275
const startedAt = new Date();
7376
const logger = getActionsLogger();
7477
let config: Config | undefined;

src/init-action-post.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ interface InitPostStatusReport
4242
initActionPostHelper.DependencyCachingUsageReport {}
4343

4444
async function runWrapper() {
45+
// To capture errors appropriately, keep as much code within the try-catch as
46+
// possible, and only use safe functions outside.
47+
4548
const logger = getActionsLogger();
4649
const startedAt = new Date();
4750
let config: Config | undefined;

src/init-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ async function sendCompletedStatusReport(
192192
}
193193

194194
async function run() {
195+
// To capture errors appropriately, keep as much code within the try-catch as
196+
// possible, and only use safe functions outside.
197+
195198
const startedAt = new Date();
196199
const logger = getActionsLogger();
197200

src/resolve-environment-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import {
3030
const ENVIRONMENT_OUTPUT_NAME = "environment";
3131

3232
async function run() {
33+
// To capture errors appropriately, keep as much code within the try-catch as
34+
// possible, and only use safe functions outside.
35+
3336
const startedAt = new Date();
3437
const logger = getActionsLogger();
3538

src/setup-codeql-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ async function sendCompletedStatusReport(
8686

8787
/** The main behaviour of this action. */
8888
async function run(): Promise<void> {
89+
// To capture errors appropriately, keep as much code within the try-catch as
90+
// possible, and only use safe functions outside.
91+
8992
const startedAt = new Date();
9093
const logger = getActionsLogger();
9194

src/start-proxy-action-post.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { getActionsLogger } from "./logging";
1313
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
1414

1515
async function runWrapper() {
16+
// To capture errors appropriately, keep as much code within the try-catch as
17+
// possible, and only use safe functions outside.
18+
1619
const logger = getActionsLogger();
1720

1821
try {

src/start-proxy-action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ async function sendSuccessStatusReport(
123123
}
124124

125125
async function runWrapper() {
126+
// To capture errors appropriately, keep as much code within the try-catch as
127+
// possible, and only use safe functions outside.
128+
126129
const startedAt = new Date();
127130

128131
const logger = getActionsLogger();

src/upload-sarif-action-post.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { getActionsLogger, withGroup } from "./logging";
1313
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
1414

1515
async function runWrapper() {
16+
// To capture errors appropriately, keep as much code within the try-catch as
17+
// possible, and only use safe functions outside.
18+
1619
try {
1720
// Restore inputs from `upload-sarif` Action.
1821
actionsUtil.restoreInputs();

0 commit comments

Comments
 (0)