3
3
using System . Reactive ;
4
4
using System . Threading . Tasks ;
5
5
using GitHub . Extensions ;
6
+ using GitHub . Logging ;
6
7
using GitHub . Models ;
7
8
using GitHub . Services ;
8
9
using ReactiveUI ;
10
+ using Serilog ;
9
11
10
12
namespace GitHub . ViewModels . GitHubPane
11
13
{
@@ -14,6 +16,8 @@ namespace GitHub.ViewModels.GitHubPane
14
16
/// </summary>
15
17
public class PullRequestReviewCommentViewModel : IPullRequestReviewFileCommentViewModel
16
18
{
19
+ static readonly ILogger log = LogManager . ForContext < PullRequestReviewCommentViewModel > ( ) ;
20
+
17
21
readonly IPullRequestEditorService editorService ;
18
22
readonly IPullRequestSession session ;
19
23
readonly PullRequestReviewCommentModel model ;
@@ -62,9 +66,10 @@ async Task DoOpen()
62
66
var file = await session . GetFile ( RelativePath , model . Thread . CommitSha ) ;
63
67
thread = file . InlineCommentThreads . FirstOrDefault ( t => t . Comments . Any ( c => c . Comment . Id == model . Id ) ) ;
64
68
65
- // Fall back to opening outdated file if we can't find a line number for the comment
66
69
if ( thread ? . LineNumber == - 1 )
67
70
{
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
68
73
file = await session . GetFile ( RelativePath , model . Thread . OriginalCommitSha ) ;
69
74
thread = file . InlineCommentThreads . FirstOrDefault ( t => t . Comments . Any ( c => c . Comment . Id == model . Id ) ) ;
70
75
}
@@ -76,9 +81,9 @@ async Task DoOpen()
76
81
await editorService . OpenDiff ( session , RelativePath , thread ) ;
77
82
}
78
83
}
79
- catch ( Exception )
84
+ catch ( Exception e )
80
85
{
81
- // TODO: Show error.
86
+ log . Error ( e , nameof ( DoOpen ) ) ;
82
87
}
83
88
}
84
89
}
0 commit comments