From 38df54baffac5056619a9f4a2b9b144a3c7fd227 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 25 Oct 2023 18:22:00 +0200 Subject: [PATCH] Exception handling on request failed HttpDownloadClient --- Tranga/MangaConnectors/HttpDownloadClient.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Tranga/MangaConnectors/HttpDownloadClient.cs b/Tranga/MangaConnectors/HttpDownloadClient.cs index 8834397..fca0dc1 100644 --- a/Tranga/MangaConnectors/HttpDownloadClient.cs +++ b/Tranga/MangaConnectors/HttpDownloadClient.cs @@ -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); + } } }