Skip to content

Commit b5f938c

Browse files
committed
Log error in restoreInputs instead of re-throwing it
1 parent fa47128 commit b5f938c

6 files changed

Lines changed: 22 additions & 15 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/actions-util.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export const persistInputs = function (env: Env = getEnv()) {
413413
/**
414414
* Restores all inputs to the action from the persisted state.
415415
*/
416-
export const restoreInputs = function () {
416+
export function restoreInputs(logger: Logger) {
417417
try {
418418
const persistedInputsValue = core.getState(persistedInputsKey);
419419
if (persistedInputsValue) {
@@ -424,9 +424,12 @@ export const restoreInputs = function () {
424424
}
425425
}
426426
} catch (err) {
427-
throw new Error(`Unable to restore inputs: ${getErrorMessage(err)}`);
427+
logger.error(`Unable to restore inputs: ${getErrorMessage(err)}`);
428+
throw new Error(
429+
"Failed to restore inputs from the state set by this action's main execution.",
430+
);
428431
}
429-
};
432+
}
430433

431434
export interface PullRequestBranches {
432435
base: string;

‎src/analyze-action-post.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export async function runWrapper() {
2525
// possible, and only use safe functions outside.
2626

2727
try {
28-
actionsUtil.restoreInputs();
2928
const logger = getActionsLogger();
29+
actionsUtil.restoreInputs(logger);
3030
const gitHubVersion = await getGitHubVersion();
3131
checkGitHubVersionInRange(gitHubVersion, logger);
3232

‎src/init-action-post.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function run(startedAt: Date) {
6262
const jobStatus = getOptionalInput("job-status");
6363

6464
// Restore inputs from `init` Action.
65-
restoreInputs();
65+
restoreInputs(logger);
6666

6767
const gitHubVersion = await getGitHubVersion();
6868
checkGitHubVersionInRange(gitHubVersion, logger);

‎src/start-proxy-action-post.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function runWrapper() {
2020

2121
try {
2222
// Restore inputs from `start-proxy` Action.
23-
actionsUtil.restoreInputs();
23+
actionsUtil.restoreInputs(logger);
2424

2525
// Kill the running proxy
2626
const pid = core.getState("proxy-process-pid");

‎src/upload-sarif-action-post.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ export async function runWrapper() {
1717
// possible, and only use safe functions outside.
1818

1919
try {
20-
// Restore inputs from `upload-sarif` Action.
21-
actionsUtil.restoreInputs();
2220
const logger = getActionsLogger();
21+
22+
// Restore inputs from `upload-sarif` Action.
23+
actionsUtil.restoreInputs(logger);
2324
const gitHubVersion = await getGitHubVersion();
2425
checkGitHubVersionInRange(gitHubVersion, logger);
2526

0 commit comments

Comments
 (0)