Skip to content

Commit 2a0d21d

Browse files
committed
fix: Improve error handling
1 parent 0d414a1 commit 2a0d21d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export function getRepoOwnerLogin(ctx: any) {
1+
export function getRepoOwnerLogin(ctx: any): string {
22
return ctx.payload.repository.owner.login
33
}
44

55
export function getRepoOwnerId(ctx: any) {
66
return ctx.payload.repository.owner.id
77
}
88

9-
export function getRepoName(ctx: any) {
9+
export function getRepoName(ctx: any): string {
1010
return ctx.payload.repository.name
1111
}
1212

src/webhooks/pull-request-closed.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ export async function pullRequestClosed(_: Probot, ctx: Context<any>) {
1818
issue_number: issueNumber
1919
});
2020
if (issueForBranch) {
21-
await ctx.octokit.issues.update({
22-
owner: owner,
23-
repo: repo,
24-
issue_number: issueNumber,
25-
state: 'closed'
26-
})
21+
await closeIssue(ctx, owner, repo, issueNumber);
2722
}
2823
}
2924
}
3025
}
26+
}
27+
28+
async function closeIssue(ctx: Context<any>, owner: string, repo: string, issueNumber: number) {
29+
try {
30+
await ctx.octokit.issues.update({
31+
owner: owner,
32+
repo: repo,
33+
issue_number: issueNumber,
34+
state: 'closed'
35+
} as any)
36+
} catch (e) {
37+
return;
38+
}
3139
}

0 commit comments

Comments
 (0)