private static void CompilePalLogger_OnErrorFound(Error e) { var executable = currentCompileProcess as CompileExecutable; if (executable != null) { executable.CompileErrors.Add(e); } if (e.Severity == 5 && IsCompiling) { //We're currently in the thread we would like to kill, so make sure we invoke from the window thread to do this. MainWindow.ActiveDispatcher.Invoke(() => { CompilePalLogger.LogLineColor("An error cancelled the compile.", Error.GetSeverityBrush(5)); CancelCompile(); ProgressManager.ErrorProgress(); }); } }
public static async void LogException(Exception e, bool crash = true) { if (!Directory.Exists(CompilePalPath.Directory + "CrashLogs")) { Directory.CreateDirectory(CompilePalPath.Directory + "CrashLogs"); } CompilePalLogger.LogLine("An exception was caught by the ExceptionHandler:"); CompilePalLogger.LogLine(e.ToString()); if (e.InnerException != null) { CompilePalLogger.LogLine(e.InnerException.ToString()); } try { AnalyticsManager.Error();//risky, but /interesting/ } catch (Exception) {} if (crash) { string crashLogName = DateTime.Now.ToString("s").Replace(":", "-"); File.WriteAllText(Path.Combine("CrashLogs", crashLogName + ".txt"), e.ToString() + e.InnerException ?? ""); ProgressManager.ErrorProgress(); var modalDialogSettings = new MetroDialogSettings { AffirmativeButtonText = "Exit", ColorScheme = MetroDialogColorScheme.Theme }; await MainWindow.Instance.ShowModal("A fatal exception has occured", e.Message, settings : modalDialogSettings); Environment.Exit(0); } }