Skip to content

Commit ea23e7b

Browse files
authored
error handling (coderabbitai#44)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Release Notes** This pull request improves error handling in the codebase. A try-catch block has been added to handle errors while replying to top-level comments. This change ensures that the application can handle errors gracefully and provide a better user experience. **Changes** - `src/review-comment.ts`: Added try-catch block to handle errors while replying to top-level comment. <!-- end of auto-generated comment: release notes by openai -->
1 parent de297f6 commit ea23e7b

File tree

2 files changed

+44
-35
lines changed

2 files changed

+44
-35
lines changed

dist/index.js

Lines changed: 21 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/review-comment.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,29 @@ Please reply to the latest comment in the conversation chain without extra prose
7070

7171
if (topLevelComment) {
7272
const topLevelCommentId = topLevelComment.id
73-
// Post the reply to the user comment
74-
await octokit.pulls.createReplyForReviewComment({
75-
owner: repo.owner,
76-
repo: repo.repo,
77-
pull_number,
78-
body: message,
79-
comment_id: topLevelCommentId
80-
})
81-
// replace COMMENT_TAG with COMMENT_REPLY_TAG in topLevelComment
82-
const newBody = topLevelComment.body.replace(
83-
COMMENT_TAG,
84-
COMMENT_REPLY_TAG
85-
)
86-
await octokit.pulls.updateReviewComment({
87-
owner: repo.owner,
88-
repo: repo.repo,
89-
comment_id: topLevelCommentId,
90-
body: newBody
91-
})
73+
try {
74+
// Post the reply to the user comment
75+
await octokit.pulls.createReplyForReviewComment({
76+
owner: repo.owner,
77+
repo: repo.repo,
78+
pull_number,
79+
body: message,
80+
comment_id: topLevelCommentId
81+
})
82+
// replace COMMENT_TAG with COMMENT_REPLY_TAG in topLevelComment
83+
const newBody = topLevelComment.body.replace(
84+
COMMENT_TAG,
85+
COMMENT_REPLY_TAG
86+
)
87+
await octokit.pulls.updateReviewComment({
88+
owner: repo.owner,
89+
repo: repo.repo,
90+
comment_id: topLevelCommentId,
91+
body: newBody
92+
})
93+
} catch (error) {
94+
core.warning(`Failed to reply to the top-level comment`)
95+
}
9296
} else {
9397
core.warning(`Failed to find the top-level comment to reply to`)
9498
}

0 commit comments

Comments
 (0)