Include version in crash msgbox

This commit is contained in:
Nikolaj Olsson 2017-04-14 17:39:48 +02:00
parent ce1473210d
commit 21a81f48f9

View File

@ -41,7 +41,7 @@ namespace Nikse.SubtitleEdit
try
{
var cap = "Windows Forms Thread Exception";
var msg = "An application error occurred in Subtitle Edit." +
var msg = "An application error occurred in Subtitle Edit " + GetVersion() + ". " +
"\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" +
"\n\nError Message:\n" + exc.Message +
"\n\nStack Trace:\n" + exc.StackTrace;
@ -57,6 +57,18 @@ namespace Nikse.SubtitleEdit
}
}
private static string GetVersion()
{
try
{
return System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
}
catch
{
return string.Empty;
}
}
// Handle the non-UI exceptions by logging the event to the ThreadException event log before
// the system default handler reports the exception to the user and terminates the application.
// NOTE: This exception handler cannot prevent the termination of the application.
@ -65,7 +77,7 @@ namespace Nikse.SubtitleEdit
try
{
var exc = e.ExceptionObject as Exception;
var msg = "A fatal non-UI error occurred in Subtitle Edit." +
var msg = "A fatal non-UI error occurred in Subtitle Edit " + GetVersion() + "." +
"\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" +
"\n\nError Message:\n" + exc.Message +
"\n\nStack Trace:\n" + exc.StackTrace;
@ -87,7 +99,7 @@ namespace Nikse.SubtitleEdit
try
{
var cap = "Non-UI Thread Exception";
var msg = "A fatal non-UI error occurred in Subtitle Edit." +
var msg = "A fatal non-UI error occurred in Subtitle Edit " + GetVersion() + "." +
"\nCould not write the error to the event log." +
"\nReason: " + ex.Message;
MessageBox.Show(msg, cap, MessageBoxButtons.OK, MessageBoxIcon.Stop);