From 052324d2769d3db1768c9c216adc040cf93171f1 Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Sat, 4 May 2024 17:07:34 +0100 Subject: [PATCH] handle not being able to fetch emoji preset --- Bloxstrap/Bootstrapper.cs | 17 ++++++++++++++--- Bloxstrap/Resources/Strings.Designer.cs | 9 +++++++++ Bloxstrap/Resources/Strings.resx | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 909c978..7113b4b 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; using Microsoft.Win32; using Bloxstrap.Integrations; +using Bloxstrap.Resources; namespace Bloxstrap { @@ -1185,9 +1186,19 @@ namespace Bloxstrap Directory.CreateDirectory(contentFonts); - var response = await App.HttpClient.GetAsync(App.Settings.Prop.EmojiType.GetUrl()); - await using var fileStream = new FileStream(emojiFontLocation, FileMode.CreateNew); - await response.Content.CopyToAsync(fileStream); + try + { + var response = await App.HttpClient.GetAsync(App.Settings.Prop.EmojiType.GetUrl()); + response.EnsureSuccessStatusCode(); + await using var fileStream = new FileStream(emojiFontLocation, FileMode.CreateNew); + await response.Content.CopyToAsync(fileStream); + } + catch (HttpRequestException ex) + { + App.Logger.WriteLine(LOG_IDENT, $"Failed to fetch emoji preset from Github: {ex}"); + Frontend.ShowMessageBox(string.Format(Strings.Bootstrapper_EmojiPresetFetchFailed, App.Settings.Prop.EmojiType), MessageBoxImage.Error); + App.Settings.Prop.EmojiType = EmojiType.Default; + } } // check custom font mod diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 2a7a0da..403f056 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -133,6 +133,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Failed to fetch the {0} emoji preset. Your preferred emoji type has been set back to default.. + /// + public static string Bootstrapper_EmojiPresetFetchFailed { + get { + return ResourceManager.GetString("Bootstrapper.EmojiPresetFetchFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to You must first install Bloxstrap before uninstalling.. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index d24de5b..cfe67d0 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -142,6 +142,9 @@ Would you like to switch to the default channel ({1})? Roblox was launched via a deeplink, however the desktop app is required for deeplink launching to work. Because you've opted to disable the desktop app, it will temporarily be re-enabled for this launch only. + + Failed to fetch the {0} emoji preset. Your preferred emoji type has been set back to default. + You must first install Bloxstrap before uninstalling.