diff --git a/dist/index.js b/dist/index.js index f27c8df..11b0695 100644 --- a/dist/index.js +++ b/dist/index.js @@ -92,6 +92,11 @@ function findComment(inputs) { return undefined; }); } +function getErrorMessage(error) { + if (error instanceof Error) + return error.message; + return String(error); +} function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -118,7 +123,7 @@ function run() { } catch (error) { core.debug((0, util_1.inspect)(error)); - core.setFailed(error.message); + core.setFailed(getErrorMessage(error)); } }); } diff --git a/src/main.ts b/src/main.ts index 704ad30..e8e6c4c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -66,6 +66,11 @@ async function findComment(inputs: Inputs): Promise { return undefined } +function getErrorMessage(error: unknown) { + if (error instanceof Error) return error.message + return String(error) +} + async function run(): Promise { try { const inputs: Inputs = { @@ -89,9 +94,9 @@ async function run(): Promise { core.setOutput('comment-body', '') core.setOutput('comment-author', '') } - } catch (error: any) { + } catch (error) { core.debug(inspect(error)) - core.setFailed(error.message) + core.setFailed(getErrorMessage(error)) } }