Skip to content

Commit 1c30005

Browse files
Copilotalexr00
andcommitted
Add error handling for getCurrentUser in variable substitution
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 65f59fb commit 1c30005

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/github/createPRViewProvider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,13 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
756756

757757
// Apply variable substitution to title and description
758758
const activeIssue = this._folderRepositoryManager.activeIssue;
759-
const currentUser = activeIssue ? (await this._folderRepositoryManager.getCurrentUser(activeIssue.githubRepository)).login : undefined;
759+
let currentUser: string | undefined;
760+
try {
761+
currentUser = activeIssue ? (await this._folderRepositoryManager.getCurrentUser(activeIssue.githubRepository)).login : undefined;
762+
} catch (e) {
763+
Logger.debug(`Failed to get current user for variable substitution: ${e}`, CreatePullRequestViewProvider.ID);
764+
currentUser = undefined;
765+
}
760766
title = variableSubstitution(title, activeIssue, this._pullRequestDefaults, currentUser);
761767
description = variableSubstitution(description, activeIssue, this._pullRequestDefaults, currentUser);
762768

0 commit comments

Comments
 (0)