Skip to content

Commit 3e4165f

Browse files
committed
use the shared error helper for Docker commands
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 18c52d9 commit 3e4165f

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎src/main.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ actionsToolkit.run(
2828
await Docker.getExecOutput(['image', 'inspect', input.image], {
2929
ignoreReturnCode: true
3030
}).then(res => {
31-
if (res.stderr.length > 0 && res.exitCode != 0) {
32-
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
31+
if (res.exitCode != 0) {
32+
throw new Error(`Failed to inspect image ${input.image}: ${Docker.getErrorMessage(res.stderr)}`);
3333
}
3434
});
3535
});
@@ -38,8 +38,8 @@ actionsToolkit.run(
3838
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--version'], {
3939
ignoreReturnCode: true
4040
}).then(res => {
41-
if (res.stderr.length > 0 && res.exitCode != 0) {
42-
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
41+
if (res.exitCode != 0) {
42+
throw new Error(`Failed to get binfmt version: ${Docker.getErrorMessage(res.stderr)}`);
4343
}
4444
});
4545
});
@@ -49,8 +49,8 @@ actionsToolkit.run(
4949
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--uninstall', 'qemu-*'], {
5050
ignoreReturnCode: true
5151
}).then(res => {
52-
if (res.stderr.length > 0 && res.exitCode != 0) {
53-
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
52+
if (res.exitCode != 0) {
53+
throw new Error(`Failed to uninstall current emulators: ${Docker.getErrorMessage(res.stderr)}`);
5454
}
5555
});
5656
});
@@ -60,8 +60,8 @@ actionsToolkit.run(
6060
await Docker.getExecOutput(['run', '--rm', '--privileged', input.image, '--install', input.platforms], {
6161
ignoreReturnCode: true
6262
}).then(res => {
63-
if (res.stderr.length > 0 && res.exitCode != 0) {
64-
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
63+
if (res.exitCode != 0) {
64+
throw new Error(`Failed to install QEMU static binaries: ${Docker.getErrorMessage(res.stderr)}`);
6565
}
6666
});
6767
});
@@ -71,8 +71,8 @@ actionsToolkit.run(
7171
ignoreReturnCode: true,
7272
silent: true
7373
}).then(res => {
74-
if (res.stderr.length > 0 && res.exitCode != 0) {
75-
throw new Error(res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error');
74+
if (res.exitCode != 0) {
75+
throw new Error(`Failed to extract available platforms: ${Docker.getErrorMessage(res.stderr)}`);
7676
}
7777
const platforms: Platforms = JSON.parse(res.stdout.trim());
7878
core.info(`${platforms.supported.join(',')}`);

0 commit comments

Comments
 (0)