Skip to content

Commit

Permalink
fix: catching exceptions when sending
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Feb 3, 2024
1 parent 7b87123 commit 325a0e8
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Mangarr.Stack/Sources/Clients/CustomHttpClient.Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ public async Task<Result<byte[]>> GetBuffer(string requestUri, CancellationToken
public async Task<Result<T>> Get<T>(string requestUri, CancellationToken ct = default)
{
HttpClient httpClient = CreateClient();
using HttpResponseMessage response = await httpClient.SendAsync(CreateGetRequest(requestUri), ct);
HttpResponseMessage response;

try
{
response = await httpClient.SendAsync(CreateGetRequest(requestUri), ct);
}
catch (Exception e)
{
return Result.Fail(new ExceptionalError(e))
.WithReason(new UrlReason(requestUri));
}

try
{
Expand Down Expand Up @@ -145,7 +155,17 @@ public async Task<Result<TAbstract>> Get<TAbstract, TConcrete>(string requestUri
where TConcrete : TAbstract
{
HttpClient httpClient = CreateClient();
using HttpResponseMessage response = await httpClient.SendAsync(CreateGetRequest(requestUri), ct);
HttpResponseMessage response;

try
{
response = await httpClient.SendAsync(CreateGetRequest(requestUri), ct);
}
catch (Exception e)
{
return Result.Fail(new ExceptionalError(e))
.WithReason(new UrlReason(requestUri));
}

try
{
Expand Down

0 comments on commit 325a0e8

Please sign in to comment.