Skip to content

Commit

Permalink
fix: replace use of any type (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans authored Oct 21, 2022
1 parent dc7862c commit b3d5f7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const github_helper_1 = __nccwpck_require__(446);
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 {
Expand Down Expand Up @@ -182,7 +187,7 @@ function run() {
}
}
catch (error) {
core.setFailed(error.message);
core.setFailed(getErrorMessage(error));
}
});
}
Expand Down
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import * as core from '@actions/core'
import {GithubHelper} from './github-helper'
import {inspect} from 'util'

function getErrorMessage(error: unknown) {
if (error instanceof Error) return error.message
return String(error)
}

async function run(): Promise<void> {
try {
const inputs = {
Expand Down Expand Up @@ -37,8 +42,8 @@ async function run(): Promise<void> {
} else {
throw Error('Failed to enable auto-merge')
}
} catch (error: any) {
core.setFailed(error.message)
} catch (error) {
core.setFailed(getErrorMessage(error))
}
}

Expand Down

0 comments on commit b3d5f7f

Please sign in to comment.