-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
39 lines (34 loc) · 1.39 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Configuration;
using System.Data;
using System.Windows;
using System.Windows.Threading;
namespace Lyra.Launcher;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
this.Dispatcher.UnhandledException += OnDispatcherUnhandledException;
}
public static void ChangeLanguage(Uri uri)
{
Application.Current.Resources.MergedDictionaries[0].Source = uri;
}
void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
if (e.Exception.InnerException != null)
{
var errorMessage = $"An unhandled exception occurred: {e.Exception.Message}\n{e.Exception.TargetSite}\n{e.Exception.StackTrace}\n{e.Exception.Source}\n{e.Exception.InnerException.Message}\n{e.Exception.InnerException.TargetSite}\n{e.Exception.InnerException.StackTrace}\n{e.Exception.InnerException.Source}";
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
var errorMessage = $"An unhandled exception occurred: {e.Exception.Message}\n{e.Exception.TargetSite}\n{e.Exception.StackTrace}\n{e.Exception.Source}";
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
e.Handled = true;
Environment.Exit(1);
}
}