Skip to content

Commit 66147ca

Browse files
authored
Merge pull request #1344 from k-kbk/add-exception-handling
refactor: add missing 'new' and exception handling
2 parents 84ad562 + 8ea72f7 commit 66147ca

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ actionsToolkit.run(
108108
if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) {
109109
// checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647
110110
// take the first line with the message summaryzing the warnings
111-
err = Error(res.stdout.split('\n')[0]?.trim());
111+
err = new Error(res.stdout.split('\n')[0]?.trim());
112112
} else if (res.stderr.length > 0) {
113-
err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
113+
err = new Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
114114
}
115115
}
116116
});
@@ -225,7 +225,11 @@ actionsToolkit.run(
225225
}
226226
if (stateHelper.tmpDir.length > 0) {
227227
await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => {
228-
fs.rmSync(stateHelper.tmpDir, {recursive: true});
228+
try {
229+
fs.rmSync(stateHelper.tmpDir, {recursive: true});
230+
} catch (e) {
231+
core.warning(`Failed to remove temp folder ${stateHelper.tmpDir}`);
232+
}
229233
});
230234
}
231235
}
@@ -285,7 +289,7 @@ function buildRecordRetentionDays(): number | undefined {
285289
if (val) {
286290
const res = parseInt(val);
287291
if (isNaN(res)) {
288-
throw Error(`Invalid build record retention days: ${val}`);
292+
throw new Error(`Invalid build record retention days: ${val}`);
289293
}
290294
return res;
291295
}

0 commit comments

Comments
 (0)