From 3b9f4f25f0395b3ffd89740edb17e72b5736b9cf Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Fri, 21 Oct 2022 15:10:59 +0900 Subject: [PATCH] fix: replace use of any type --- dist/index.js | 7 ++++++- src/main.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index a1991d0..3daa816 100644 --- a/dist/index.js +++ b/dist/index.js @@ -212,6 +212,11 @@ const inputHelper = __importStar(__nccwpck_require__(5480)); const dockerhubHelper = __importStar(__nccwpck_require__(1812)); const fs = __importStar(__nccwpck_require__(7147)); const util_1 = __nccwpck_require__(3837); +function getErrorMessage(error) { + if (error instanceof Error) + return error.message; + return String(error); +} function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -232,7 +237,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 ed90337..55e0aa9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,11 @@ import * as dockerhubHelper from './dockerhub-helper' import * as fs from 'fs' import {inspect} from 'util' +function getErrorMessage(error: unknown) { + if (error instanceof Error) return error.message + return String(error) +} + async function run(): Promise { try { const inputs = inputHelper.getInputs() @@ -31,9 +36,9 @@ async function run(): Promise { readmeContent ) core.info('Request successful') - } catch (error: any) { + } catch (error) { core.debug(inspect(error)) - core.setFailed(error.message) + core.setFailed(getErrorMessage(error)) } }