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

Commit 1219ae1

Browse files
committed
Add logging to PullRequestReviewCommentViewModel
1 parent 9b40871 commit 1219ae1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestReviewCommentViewModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using System.Reactive;
44
using System.Threading.Tasks;
55
using GitHub.Extensions;
6+
using GitHub.Logging;
67
using GitHub.Models;
78
using GitHub.Services;
89
using ReactiveUI;
10+
using Serilog;
911

1012
namespace GitHub.ViewModels.GitHubPane
1113
{
@@ -14,6 +16,8 @@ namespace GitHub.ViewModels.GitHubPane
1416
/// </summary>
1517
public class PullRequestReviewCommentViewModel : IPullRequestReviewFileCommentViewModel
1618
{
19+
static readonly ILogger log = LogManager.ForContext<PullRequestReviewCommentViewModel>();
20+
1721
readonly IPullRequestEditorService editorService;
1822
readonly IPullRequestSession session;
1923
readonly PullRequestReviewCommentModel model;
@@ -62,9 +66,10 @@ async Task DoOpen()
6266
var file = await session.GetFile(RelativePath, model.Thread.CommitSha);
6367
thread = file.InlineCommentThreads.FirstOrDefault(t => t.Comments.Any(c => c.Comment.Id == model.Id));
6468

65-
// Fall back to opening outdated file if we can't find a line number for the comment
6669
if(thread?.LineNumber == -1)
6770
{
71+
log.Warning("Couldn't find line number for comment on {RelativePath} @ {CommitSha}", RelativePath, model.Thread.CommitSha);
72+
// Fall back to opening outdated file if we can't find a line number for the comment
6873
file = await session.GetFile(RelativePath, model.Thread.OriginalCommitSha);
6974
thread = file.InlineCommentThreads.FirstOrDefault(t => t.Comments.Any(c => c.Comment.Id == model.Id));
7075
}
@@ -76,9 +81,9 @@ async Task DoOpen()
7681
await editorService.OpenDiff(session, RelativePath, thread);
7782
}
7883
}
79-
catch (Exception)
84+
catch (Exception e)
8085
{
81-
// TODO: Show error.
86+
log.Error(e, nameof(DoOpen));
8287
}
8388
}
8489
}

0 commit comments

Comments
 (0)