diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 75406466..2f049814 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -73,14 +73,7 @@ namespace Vocaluxe } catch (Exception e) { - string stackTrace = ""; - try - { - stackTrace = e.StackTrace; - } - catch {} - MessageBox.Show("Unhandled error: " + e.Message + stackTrace); - CLog.Error("Unhandled error: " + e.Message + stackTrace); + CLog.Fatal(e, "Unhandled error: {ErrorMessage}", CLog.Params(e.Message)); } #else _Run(args); diff --git a/VocaluxeLib/Log/CLog.cs b/VocaluxeLib/Log/CLog.cs index 92b9328c..4c9cb746 100644 --- a/VocaluxeLib/Log/CLog.cs +++ b/VocaluxeLib/Log/CLog.cs @@ -50,7 +50,7 @@ namespace VocaluxeLib.Log /// The name of the log for song problems. /// The name of the file which is used as crash marker. /// The current version tag as it is displayed in the main menu. - /// Delegate to the function wchih should be called if the reporter have to been shown. + /// Delegate to the function which should be called if the reporter have to been shown. public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc) { _LogFolder = logFolder; @@ -156,6 +156,12 @@ namespace VocaluxeLib.Log _MainLogStringWriter.Flush(); // Show the Reporter _ShowReporterFunc(crash: crash, showContinue: showContinue, vocaluxeVersionTag: _CurrentVersion, log: _MainLogStringBuilder.ToString(), lastError: _FormatMessageTemplate(messageTemplate, propertyValues)); + + // Delete the crash marker (we do not want to show this error again on the next restart) + if (!showContinue) + { + File.Delete(_CrashMarkerFilePath); + } } /// diff --git a/VocaluxeLib/Log/Rolling/CLogFileRoller.cs b/VocaluxeLib/Log/Rolling/CLogFileRoller.cs index 89c466a4..eed3ccdd 100644 --- a/VocaluxeLib/Log/Rolling/CLogFileRoller.cs +++ b/VocaluxeLib/Log/Rolling/CLogFileRoller.cs @@ -73,7 +73,7 @@ namespace VocaluxeLib.Log.Rolling private static void _DeleteOldLogs(string mainLogFile, int numLogsToKeep) { - Regex r = new Regex($"{Path.GetDirectoryName(mainLogFile)}\\\\{Path.GetFileNameWithoutExtension(mainLogFile)}_([0-9]+){Path.GetExtension(mainLogFile)}", RegexOptions.IgnoreCase); + Regex r = new Regex($"{Path.GetDirectoryName(mainLogFile)}\\{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(mainLogFile)}_([0-9]+){Path.GetExtension(mainLogFile)}", RegexOptions.IgnoreCase); IEnumerable logFiles = Directory.EnumerateFiles($"{Path.GetDirectoryName(mainLogFile)}", $"{Path.GetFileNameWithoutExtension(mainLogFile)}*{Path.GetExtension(mainLogFile)}"); foreach (string file in logFiles) { @@ -104,7 +104,7 @@ namespace VocaluxeLib.Log.Rolling private static string _GenerateRollLogFileName(string mainLogFile, int number) { - return $"{Path.GetDirectoryName(mainLogFile)}\\{Path.GetFileNameWithoutExtension(mainLogFile)}_{number}{Path.GetExtension(mainLogFile)}"; + return $"{ Path.GetDirectoryName(mainLogFile) }{ Path.DirectorySeparatorChar }{ Path.GetFileNameWithoutExtension(mainLogFile) }_{ number }{ Path.GetExtension(mainLogFile) }"; } } }