Skip to content

Commit

Permalink
Display unhandled exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Sep 7, 2024
1 parent 4ca7463 commit 72a85fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions NET48/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ internal static class Program {
static void Main(string[] args) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.Run(new FindInFilesForm(args));
}

private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
var exc = e.ExceptionObject as Exception;
MessageBox.Show(exc?.StackTrace, exc?.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
6 changes: 6 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ static void Main(string[] args) {
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.Run(new FindInFilesForm(args));
}

private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
var exc = e.ExceptionObject as Exception;
MessageBox.Show(exc?.StackTrace, exc?.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

0 comments on commit 72a85fd

Please sign in to comment.