Skip to content

Commit 22456f1

Browse files
committed
fix: fix error handling
1 parent 52fad73 commit 22456f1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/channel_windows.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import * as exec from "@actions/exec";
66
import * as core from "@actions/core";
77
import fs from "fs";
88

9+
const isENOENT = (e: unknown): boolean => {
10+
return (
11+
typeof e === "object" && e !== null && "code" in e && e.code === "ENOENT"
12+
);
13+
};
14+
915
export class WindowsChannelInstaller implements Installer {
1016
constructor(private readonly platform: Platform) {}
1117

@@ -18,7 +24,7 @@ export class WindowsChannelInstaller implements Installer {
1824
try {
1925
await fs.promises.stat(root);
2026
} catch (e) {
21-
if (e.code === "ENOENT") {
27+
if (isENOENT(e)) {
2228
return undefined;
2329
}
2430
throw e;

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import * as installer from "./installer";
55
import { getPlatform, OS } from "./platform";
66
import path from "path";
77

8+
const hasErrorMessage = (e: unknown): e is { message: string | Error } => {
9+
return typeof e === "object" && e !== null && "message" in e;
10+
};
11+
812
async function run(): Promise<void> {
913
try {
1014
const version = core.getInput("chrome-version") || "latest";
@@ -26,7 +30,11 @@ async function run(): Promise<void> {
2630
await exec.exec(binName, ["--version"]);
2731
}
2832
} catch (error) {
29-
core.setFailed(error.message);
33+
if (hasErrorMessage(error)) {
34+
core.setFailed(error.message);
35+
} else {
36+
console.error(error)
37+
}
3038
}
3139
}
3240

0 commit comments

Comments
 (0)