Skip to content

Commit 5a2b25f

Browse files
committed
feat(logging): add logging for unhandled exceptions
1 parent 542d8c3 commit 5a2b25f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/MCServerLauncher.WPF/App.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99
using System.Windows;
10+
using Serilog;
1011
using Clipboard = MCServerLauncher.WPF.Modules.Clipboard;
1112
using ExceptionWindow = MCServerLauncher.WPF.ExceptionDialog.Window;
1213

@@ -100,6 +101,7 @@ private void App_DispatcherUnhandledException(object sender, System.Windows.Thre
100101
Clipboard.SetText(e.Exception.ToString());
101102
new ExceptionWindow(e.Exception.ToString()).ShowDialog();
102103
e.Handled = true;
104+
Log.Error("Unhandled UI Exception", e.Exception);
103105
}
104106

105107
private void AppDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
@@ -133,6 +135,10 @@ private void AppDomain_UnhandledException(object sender, UnhandledExceptionEvent
133135

134136
}
135137
}
138+
finally
139+
{
140+
Log.Fatal("Unhandled Non-UI Exception", exception);
141+
}
136142
}
137143

138144
private void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
@@ -155,6 +161,10 @@ private void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTas
155161
{
156162

157163
}
164+
finally
165+
{
166+
Log.Error("Unobserved Task Exception", exception);
167+
}
158168
}
159169
}
160170
}

0 commit comments

Comments
 (0)