Merge pull request #37 from Mixone-FinallyHere/dev-kuha

optimized crash report & remove calls to windows report handler
This commit is contained in:
Miguel 2025-07-16 13:05:13 +02:00 committed by GitHub
commit 6de292e2de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,23 +24,7 @@ namespace DSPRE
private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var exception = e.ExceptionObject as Exception;
string crashReport = BuildCrashReport(exception);
string filePath = GetCrashReportFilePath();
try
{
File.WriteAllText(filePath, crashReport, Encoding.UTF8);
}
catch
{
try
{
EventLog.WriteEntry("Application", crashReport, EventLogEntryType.Error);
}
catch { }
}
WriteCrashReport(e.ExceptionObject as Exception);
}
private static void HandleThreadException(object sender, ThreadExceptionEventArgs e)
@ -65,34 +49,22 @@ namespace DSPRE
}
catch
{
try
{
EventLog.WriteEntry("Application", crashReport, EventLogEntryType.Error);
}
catch { }
}
try
DialogResult result = MessageBox.Show(
$"An unexpected error occurred and the application crashed.\n\nA crash report was saved here:\n{filePath}\n\nClick OK to open the folder.",
"Application Error",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Error
);
if (result == DialogResult.OK)
{
DialogResult result = MessageBox.Show(
$"An unexpected error occurred and the application crashed.\n\nA crash report was saved here:\n{filePath}\n\nClick OK to open the folder.",
"Application Error",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Error
);
if (result == DialogResult.OK)
{
// Open Explorer and select the crash report
Process.Start("explorer.exe", $"/select,\"{filePath}\"");
}
Helpers.ExplorerSelect(filePath);
}
catch { }
}
private static string BuildCrashReport(Exception ex)
{
var sb = new StringBuilder();