Skip to content

Commit

Permalink
Merge pull request #73 from peter-evans/fix-any
Browse files Browse the repository at this point in the history
fix: replace use of any type
  • Loading branch information
peter-evans committed Oct 21, 2022
2 parents b657a70 + 1e663f0 commit 1c328ad
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
Expand Up @@ -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 {
Expand All @@ -118,7 +123,7 @@ function run() {
}
catch (error) {
core.debug((0, util_1.inspect)(error));
core.setFailed(error.message);
core.setFailed(getErrorMessage(error));
}
});
}
Expand Down
9 changes: 7 additions & 2 deletions src/main.ts
Expand Up @@ -66,6 +66,11 @@ async function findComment(inputs: Inputs): Promise<Comment | undefined> {
return undefined
}

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

async function run(): Promise<void> {
try {
const inputs: Inputs = {
Expand All @@ -89,9 +94,9 @@ async function run(): Promise<void> {
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))
}
}

Expand Down

0 comments on commit 1c328ad

Please sign in to comment.