Skip to content

Commit

Permalink
Merge pull request #628 from peter-evans/fix-any
Browse files Browse the repository at this point in the history
Replace use of any type
  • Loading branch information
peter-evans authored Oct 21, 2022
2 parents ebb3089 + 52f0597 commit 6b58086
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function run() {
}
catch (error) {
core.debug((0, util_1.inspect)(error));
core.setFailed(error.message);
core.setFailed(utils.getErrorMessage(error));
}
});
}
Expand Down Expand Up @@ -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));
Expand All @@ -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;


/***/ }),
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ async function run(): Promise<void> {
} 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))
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 6b58086

Please sign in to comment.