Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle clipboard copying exceptions #2103

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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