Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
feat: popup on crash
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-wff committed Dec 14, 2023
1 parent 4335d86 commit afc104b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
16 changes: 16 additions & 0 deletions EasyGUI/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Windows;
using System.Windows.Threading;
using EasyGUI.Resources;
using EasyLib.Files;
using MessageBox = System.Windows.MessageBox;

namespace EasyGUI;

Expand All @@ -11,6 +14,19 @@ public partial class App
protected override void OnStartup(StartupEventArgs e)
{
Thread.CurrentThread.CurrentUICulture = ConfigManager.Instance.Language;
Dispatcher.UnhandledException += OnDispatcherUnhandledException;
base.OnStartup(e);
}

private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
Console.Error.WriteLine(e.Exception);
MessageBox.Show(
string.Format(Strings.App_CrashPopup_Message, e.Exception.Message),
Strings.App_CrashPopup_Title,
MessageBoxButton.OK,
MessageBoxImage.Error
);
Environment.Exit(1);
}
}
20 changes: 20 additions & 0 deletions EasyGUI/Resources/Strings.Designer.cs

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

20 changes: 20 additions & 0 deletions EasyGUI/Resources/Strings.fr.Designer.cs

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

8 changes: 8 additions & 0 deletions EasyGUI/Resources/Strings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,12 @@
<data name="MainWindow_InstanceError_Message" xml:space="preserve">
<value>Une instance de cette application est déjà en cours d'exécution. Veuillez la fermer en premier.</value>
</data>
<data name="App_CrashPopup_Title" xml:space="preserve">
<value>Erreur imprévue</value>
</data>
<data name="App_CrashPopup_Message" xml:space="preserve">
<value>Une erreur inconnue est survenue : {0}

Nous nous excusons pour la gêne occasionnée.</value>
</data>
</root>
8 changes: 8 additions & 0 deletions EasyGUI/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,12 @@
<data name="MainWindow_InstanceError_Message" xml:space="preserve">
<value>An instance of this application is already running. Please close it first.</value>
</data>
<data name="App_CrashPopup_Title" xml:space="preserve">
<value>Unhandled error</value>
</data>
<data name="App_CrashPopup_Message" xml:space="preserve">
<value>An unknown error occurred: {0}

We are sorry for this inconvenience.</value>
</data>
</root>

0 comments on commit afc104b

Please sign in to comment.