Skip to content

Commit

Permalink
handle clipboard copying exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepilledgreat committed Jun 18, 2024
1 parent e8d3114 commit 845b5b7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<data name="Bootstrapper.AutoUpdateFailed" xml:space="preserve">
<value>Bloxstrap was unable to auto-update to {0}. Please update it manually by downloading and running the latest release from the GitHub page.</value>
</data>
<data name="Bootstrapper.ClipboardCopyFailed" xml:space="preserve">
<value>Failed to copy to the clipboard: {0}</value>
</data>
<data name="Bootstrapper.ConfirmLaunch" xml:space="preserve">
<value>Roblox is currently running, and launching another instance will close it. Are you sure you want to continue launching?</value>
</data>
Expand Down
14 changes: 13 additions & 1 deletion Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Media;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
Expand Down Expand Up @@ -30,9 +31,20 @@ public ExceptionDialog(Exception exception)
LocateLogFileButton.Click += delegate
{
if (App.Logger.Initialized)
{
Process.Start("explorer.exe", $"/select,\"{App.Logger.FileLocation}\"");
}
else
Clipboard.SetDataObject(String.Join("\r\n", App.Logger.Backlog));
{
try
{
Clipboard.SetText(String.Join("\r\n", App.Logger.Backlog));
}
catch (COMException ex)
{
Frontend.ShowMessageBox(string.Format(Bloxstrap.Resources.Strings.Bootstrapper_ClipboardCopyFailed, ex.Message), MessageBoxImage.Error);
}
}
};

ReportOptions.DropDownClosed += (sender, e) =>
Expand Down
17 changes: 16 additions & 1 deletion Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Wpf.Ui.Mvvm.Contracts;

using Bloxstrap.UI.Elements.Dialogs;
using System.Runtime.InteropServices;

namespace Bloxstrap.UI.Elements.Menu.Pages
{
Expand Down Expand Up @@ -341,8 +342,22 @@ private void ToggleButton_Click(object sender, RoutedEventArgs e)

private void ExportJSONButton_Click(object sender, RoutedEventArgs e)
{
const string LOG_IDENT = "FastFlagEditorPage::ExportJSONButton_Click";

string json = JsonSerializer.Serialize(App.FastFlags.Prop, new JsonSerializerOptions { WriteIndented = true });
Clipboard.SetText(json);

try
{
Clipboard.SetText(json);
}
catch (COMException ex)
{
App.Logger.WriteLine(LOG_IDENT, "Failed to copy to the clipboard");
App.Logger.WriteException(LOG_IDENT, ex);
Frontend.ShowMessageBox(string.Format(Bloxstrap.Resources.Strings.Bootstrapper_ClipboardCopyFailed, ex.Message), MessageBoxImage.Error);
return;
}

Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_JsonCopiedToClipboard, MessageBoxImage.Information);
}

Expand Down

0 comments on commit 845b5b7

Please sign in to comment.