Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 76767aa

Browse files
committed
Avoid a first-chance exception in WebRequestFactory.GetStringAsync().
1 parent b9a023a commit 76767aa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ProjectFileTools.NuGetSearch/IO/WebRequestFactory.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public async Task<string> GetStringAsync(string endpoint, CancellationToken canc
1212
try
1313
{
1414
HttpResponseMessage responseMessage = await _httpClient.GetAsync(endpoint, cancellationToken).ConfigureAwait(false);
15+
if (responseMessage.StatusCode == System.Net.HttpStatusCode.NotFound)
16+
{
17+
// avoid a first-chance exception on 404
18+
return null;
19+
}
20+
1521
responseMessage.EnsureSuccessStatusCode();
1622
return await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
1723
}

0 commit comments

Comments
 (0)