From 20eeba0d49c75152ddef2cbca1f69e67a3801afd Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:04:38 -0400 Subject: [PATCH] Fix emote provider HTTPRequestException message assuming an HTTP status code exists --- TwitchDownloaderCore/TwitchHelper.cs | 30 +++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/TwitchDownloaderCore/TwitchHelper.cs b/TwitchDownloaderCore/TwitchHelper.cs index 71f9be56..a3816eef 100644 --- a/TwitchDownloaderCore/TwitchHelper.cs +++ b/TwitchDownloaderCore/TwitchHelper.cs @@ -404,7 +404,15 @@ public static async Task> GetThirdPartyEmotes(List co } catch (HttpRequestException e) { - logger.LogError($"BetterTTV returned HTTP {e.StatusCode}. BTTV emotes may not be present for this session."); + var message = e.StatusCode != null + ? $"BetterTTV returned HTTP {e.StatusCode}." + : e.Message; + + logger.LogError($"{message} Some BTTV emotes may not be present for this session."); + } + catch (TaskCanceledException ex) when (ex.Message.Contains("HttpClient.Timeout")) + { + logger.LogError("BetterTTV timed out. Some BTTV emotes may not be present for this session."); } } @@ -416,7 +424,15 @@ public static async Task> GetThirdPartyEmotes(List co } catch (HttpRequestException e) { - logger.LogError($"FFZ returned HTTP {e.StatusCode}. FFZ emotes may not be present for this session."); + var message = e.StatusCode != null + ? $"FFZ returned HTTP {e.StatusCode}." + : e.Message; + + logger.LogError($"{message} Some FFZ emotes may not be present for this session."); + } + catch (TaskCanceledException ex) when (ex.Message.Contains("HttpClient.Timeout")) + { + logger.LogError("FFZ timed out. Some FFZ emotes may not be present for this session."); } } @@ -428,7 +444,15 @@ public static async Task> GetThirdPartyEmotes(List co } catch (HttpRequestException e) { - logger.LogError($"7TV returned HTTP {e.StatusCode}. 7TV emotes may not be present for this session."); + var message = e.StatusCode != null + ? $"7TV returned HTTP {e.StatusCode}." + : e.Message; + + logger.LogError($"{message} Some 7TV emotes may not be present for this session."); + } + catch (TaskCanceledException ex) when (ex.Message.Contains("HttpClient.Timeout")) + { + logger.LogError("7TV timed out. Some 7TV emotes may not be present for this session."); } }