diff --git a/dist/index.js b/dist/index.js index 2a84e29..07d0455 100644 --- a/dist/index.js +++ b/dist/index.js @@ -117,7 +117,7 @@ function run() { } catch (error) { core.debug((0, util_1.inspect)(error)); - core.setFailed(error.message); + core.setFailed(utils.getErrorMessage(error)); } }); } @@ -151,7 +151,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getStringAsArray = exports.getInputAsArray = void 0; +exports.getErrorMessage = exports.getStringAsArray = exports.getInputAsArray = void 0; const core = __importStar(__nccwpck_require__(2186)); function getInputAsArray(name, options) { return getStringAsArray(core.getInput(name, options)); @@ -164,6 +164,12 @@ function getStringAsArray(str) { .filter(x => x !== ''); } exports.getStringAsArray = getStringAsArray; +function getErrorMessage(error) { + if (error instanceof Error) + return error.message; + return String(error); +} +exports.getErrorMessage = getErrorMessage; /***/ }), diff --git a/src/main.ts b/src/main.ts index 1ea644b..4c5bb7f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -81,9 +81,9 @@ async function run(): Promise { } else { core.info(`File not found at path '${inputs.contentFilepath}'`) } - } catch (error: any) { + } catch (error) { core.debug(inspect(error)) - core.setFailed(error.message) + core.setFailed(utils.getErrorMessage(error)) } } diff --git a/src/utils.ts b/src/utils.ts index 59b21e7..52dc897 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -13,3 +13,8 @@ export function getStringAsArray(str: string): string[] { .map(s => s.trim()) .filter(x => x !== '') } + +export function getErrorMessage(error: unknown) { + if (error instanceof Error) return error.message + return String(error) +}