Skip to content

Commit

Permalink
Handle top-level errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Apr 2, 2022
1 parent b01a479 commit 660ab93
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
22 changes: 16 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8474,13 +8474,23 @@ const github = __importStar(__nccwpck_require__(5438));
const approve_1 = __nccwpck_require__(6609);
function run() {
return __awaiter(this, void 0, void 0, function* () {
const token = core.getInput("github-token", { required: true });
const prNumber = parseInt(core.getInput("pull-request-number"), 10);
if (!Number.isNaN(prNumber)) {
yield (0, approve_1.approve)(token, github.context, prNumber);
try {
const token = core.getInput("github-token", { required: true });
const prNumber = parseInt(core.getInput("pull-request-number"), 10);
if (!Number.isNaN(prNumber)) {
yield (0, approve_1.approve)(token, github.context, prNumber);
}
else {
yield (0, approve_1.approve)(token, github.context);
}
}
else {
yield (0, approve_1.approve)(token, github.context);
catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
else {
core.setFailed("Unknown error");
}
}
});
}
Expand Down
20 changes: 14 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ import * as github from "@actions/github";
import { approve } from "./approve";

async function run() {
const token = core.getInput("github-token", { required: true });
const prNumber: number = parseInt(core.getInput("pull-request-number"), 10);
if (!Number.isNaN(prNumber)) {
await approve(token, github.context, prNumber);
} else {
await approve(token, github.context);
try {
const token = core.getInput("github-token", { required: true });
const prNumber: number = parseInt(core.getInput("pull-request-number"), 10);
if (!Number.isNaN(prNumber)) {
await approve(token, github.context, prNumber);
} else {
await approve(token, github.context);
}
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
} else {
core.setFailed("Unknown error");
}
}
}

Expand Down

0 comments on commit 660ab93

Please sign in to comment.