-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
45 lines (39 loc) · 1.39 KB
/
App.xaml.cs
File metadata and controls
45 lines (39 loc) · 1.39 KB
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
40
41
42
43
44
45
using LolibarApp.Source.Tools;
using System.Diagnostics;
using System.Windows.Forms;
namespace LolibarApp;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : System.Windows.Application
{
App()
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception exception = (Exception)e.ExceptionObject;
// Idk, strange bug with async lolibar stuff, i don't care to fix it now.
// Just for note: Threading.Dispatcher causes this.
if (exception.Source != null && exception.Source.Contains("WindowsBase"))
{
return;
}
DialogResult result = LolibarMessageBox.Show
(
text: $"{exception.Source}.exe caught an error.\n\nError: {exception.Message}\n{exception.InnerException}\n{exception.StackTrace}\n\nDo you want to restart the application?",
title: "Lolibar Alert",
MessageBoxButtons.YesNo
);
if (result == DialogResult.Yes)
{
LolibarHelper.RestartApplicationGently();
}
if (result == DialogResult.No)
{
//LolibarHelper.CloseApplicationGently();
Process.GetCurrentProcess().Kill();
}
}
}