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

Commit 1744375

Browse files
committed
Don't use FileNotFoundException for non-IO operation
Fixed `if (`.
1 parent bf27bc6 commit 1744375

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public IObservable<Tuple<string, string>> ExtractDiffFiles(
309309
string mergeBase = await gitClient.GetPullRequestMergeBase(repo, remote.Name, baseSha, headSha, baseRef, pullRequest.Number);
310310
if (mergeBase == null)
311311
{
312-
throw new FileNotFoundException($"Couldn't find merge base between {baseSha} and {headSha}.");
312+
throw new InvalidOperationException($"Couldn't find merge base between {baseSha} and {headSha}.");
313313
}
314314

315315
string left;
@@ -349,7 +349,7 @@ static bool HasPreamble(string file, Encoding encoding)
349349
{
350350
foreach (var b in encoding.GetPreamble())
351351
{
352-
if(b != stream.ReadByte())
352+
if (b != stream.ReadByte())
353353
{
354354
return false;
355355
}

src/UnitTests/GitHub.App/Services/PullRequestServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async void MergeBaseNotAvailable_ThrowsFileNotFoundException()
6868
var checkedOut = false;
6969
var expectMessage = $"Couldn't find merge base between {baseSha} and {headSha}.";
7070

71-
var ex = await Assert.ThrowsAsync<FileNotFoundException>(() => ExtractDiffFiles(baseSha, baseFileContent, headSha, headFileContent, mergeBaseSha, mergeBaseFileContent,
71+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => ExtractDiffFiles(baseSha, baseFileContent, headSha, headFileContent, mergeBaseSha, mergeBaseFileContent,
7272
fileName, checkedOut));
7373
Assert.Equal(expectMessage, ex.Message);
7474
}

0 commit comments

Comments
 (0)