diff --git a/API/MangaDownloadClients/DownloadClient.cs b/API/MangaDownloadClients/DownloadClient.cs index d930852..c611a33 100644 --- a/API/MangaDownloadClients/DownloadClient.cs +++ b/API/MangaDownloadClients/DownloadClient.cs @@ -1,14 +1,16 @@ using System.Net; -using API.Schema; +using log4net; namespace API.MangaDownloadClients; internal abstract class DownloadClient { private readonly Dictionary _lastExecutedRateLimit; + protected ILog Log { get; init; } protected DownloadClient() { + this.Log = LogManager.GetLogger(GetType()); this._lastExecutedRateLimit = new(); } diff --git a/API/MangaDownloadClients/HttpDownloadClient.cs b/API/MangaDownloadClients/HttpDownloadClient.cs index 332cfab..b72b29b 100644 --- a/API/MangaDownloadClients/HttpDownloadClient.cs +++ b/API/MangaDownloadClients/HttpDownloadClient.cs @@ -48,8 +48,17 @@ internal class HttpDownloadClient : DownloadClient { return new RequestResult(response.StatusCode, null, Stream.Null); } - - Stream stream = response.Content.ReadAsStream(); + + Stream stream; + try + { + stream = response.Content.ReadAsStream(); + } + catch (Exception e) + { + Log.Error(e); + return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null); + } HtmlDocument? document = null;