From 29f6de2590e4d1e97634864775b88b6195d5d5f8 Mon Sep 17 00:00:00 2001 From: Glax Date: Sun, 24 Dec 2023 16:27:20 +0100 Subject: [PATCH] Catch parsing error #93 to prevent crashes and restart loops --- Tranga/MangaConnectors/MangaConnector.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Tranga/MangaConnectors/MangaConnector.cs b/Tranga/MangaConnectors/MangaConnector.cs index 037a938..9f0648a 100644 --- a/Tranga/MangaConnectors/MangaConnector.cs +++ b/Tranga/MangaConnectors/MangaConnector.cs @@ -64,9 +64,19 @@ public abstract class MangaConnector : GlobalBase && chapterNumber > manga.ignoreChaptersBelow && !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList(); Log($"{newChaptersList.Count} new chapters. {manga}"); - Chapter latestChapterAvailable = - allChapters.MaxBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)); - manga.latestChapterAvailable = Convert.ToSingle(latestChapterAvailable.chapterNumber, numberFormatDecimalPoint); + try + { + Chapter latestChapterAvailable = + allChapters.MaxBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint)); + manga.latestChapterAvailable = + Convert.ToSingle(latestChapterAvailable.chapterNumber, numberFormatDecimalPoint); + } + catch (FormatException f) + { + Log(f.ToString()); + Log($"Failed getting new Chapters for {manga}"); + return Array.Empty(); + } return newChaptersList.ToArray(); }