Skip to content

Commit 24a97b6

Browse files
Copilotalexr00
andcommitted
Improve error handling for Ready & Merge button
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 62b51ca commit 24a97b6

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/github/pullRequestOverview.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,15 +657,27 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
657657
const readyResult = await this._item.setReadyForReview();
658658

659659
// Step 2: Approve the PR
660-
await this._item.approve(this._folderRepositoryManager.repository, '');
660+
try {
661+
await this._item.approve(this._folderRepositoryManager.repository, '');
662+
} catch (e) {
663+
vscode.window.showErrorMessage(`Pull request marked as ready for review, but failed to approve. ${formatError(e)}`);
664+
this._replyMessage(message, readyResult);
665+
return;
666+
}
661667

662668
// Step 3: Enable auto-merge
663-
await this._item.enableAutoMerge(message.args.mergeMethod);
669+
try {
670+
await this._item.enableAutoMerge(message.args.mergeMethod);
671+
} catch (e) {
672+
vscode.window.showErrorMessage(`Pull request marked as ready and approved, but failed to enable auto-merge. ${formatError(e)}`);
673+
this._replyMessage(message, readyResult);
674+
return;
675+
}
664676

665677
// Return the ready result to update the UI
666678
this._replyMessage(message, readyResult);
667679
} catch (e) {
668-
vscode.window.showErrorMessage(`Unable to mark ready for review and merge. ${formatError(e)}`);
680+
vscode.window.showErrorMessage(`Unable to mark pull request as ready for review. ${formatError(e)}`);
669681
this._throwError(message, '');
670682
}
671683
}

0 commit comments

Comments
 (0)