Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit a98c74a

Browse files
authored
Merge pull request #683 from github/fixes/catch-startup-errors
Catch exceptions thrown in GitHubConnectSection.
2 parents 75472b4 + c34b900 commit a98c74a

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,20 @@ async void UpdateRepositoryList(object sender, NotifyCollectionChangedEventArgs
216216
HandleClonedRepo(newrepo);
217217

218218
isCreating = isCloning = false;
219-
var repo = await ApiFactory.Create(newrepo.CloneUrl).GetRepository();
220-
newrepo.SetIcon(repo.Private, repo.Fork);
219+
220+
try
221+
{
222+
// TODO: Cache the icon state.
223+
var repo = await ApiFactory.Create(newrepo.CloneUrl).GetRepository();
224+
newrepo.SetIcon(repo.Private, repo.Fork);
225+
}
226+
catch
227+
{
228+
// GetRepository() may throw if the user doesn't have permissions to access the repo
229+
// (because the repo no longer exists, or because the user has logged in on a different
230+
// profile, or their permissions have changed remotely)
231+
// TODO: Log
232+
}
221233
}
222234
// looks like it's just a refresh with new stuff on the list, update the icons
223235
else
@@ -228,8 +240,20 @@ async void UpdateRepositoryList(object sender, NotifyCollectionChangedEventArgs
228240
{
229241
if (Equals(Holder.ActiveRepo, r))
230242
SelectedRepository = r;
231-
var repo = await ApiFactory.Create(r.CloneUrl).GetRepository();
232-
r.SetIcon(repo.Private, repo.Fork);
243+
244+
try
245+
{
246+
// TODO: Cache the icon state.
247+
var repo = await ApiFactory.Create(r.CloneUrl).GetRepository();
248+
r.SetIcon(repo.Private, repo.Fork);
249+
}
250+
catch
251+
{
252+
// GetRepository() may throw if the user doesn't have permissions to access the repo
253+
// (because the repo no longer exists, or because the user has logged in on a different
254+
// profile, or their permissions have changed remotely)
255+
// TODO: Log
256+
}
233257
});
234258
}
235259
}

0 commit comments

Comments
 (0)