2
0

Exception handling on request failed HttpDownloadClient

This commit is contained in:
glax 2023-10-25 18:22:00 +02:00
parent 98d187d133
commit 38df54baff

View File

@ -37,10 +37,17 @@ internal class HttpDownloadClient : DownloadClient
{
response = Client.Send(requestMessage);
}
catch (TaskCanceledException e)
catch (Exception e)
{
Log($"Request timed out.\n\r{e}");
return new RequestResult(HttpStatusCode.RequestTimeout, null, Stream.Null);
switch (e)
{
case TaskCanceledException:
Log($"Request timed out.\n\r{e}");
return new RequestResult(HttpStatusCode.RequestTimeout, null, Stream.Null);
case HttpRequestException:
Log($"Request failed\n\r{e}");
return new RequestResult(HttpStatusCode.BadRequest, null, Stream.Null);
}
}
}