private static void SendReport(string exceptionMessage) { var crashReport = new CrashReportData { ["Application"] = "Launcher", ["UserEmail"] = "", ["UserMessage"] = "", ["CurrentDirectory"] = Environment.CurrentDirectory, ["CommandArgs"] = string.Join(" ", AppHelper.GetCommandLineArgs()), ["OsVersion"] = $"{Environment.OSVersion} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}", ["ProcessorCount"] = Environment.ProcessorCount.ToString(), ["Exception"] = exceptionMessage }; var videoConfig = AppHelper.GetVideoConfig(); foreach (var conf in videoConfig) { crashReport.Data.Add(Tuple.Create(conf.Key, conf.Value)); } var reporter = new CrashReportForm(crashReport, new CrashReportSettings()); reporter.ShowDialog(); }
private static void ReportException(Exception e) { CrashReportForm form = new CrashReportForm(); form.Exception = e; form.ShowDialog(); }
private static void UnhandledExceptionReporting(object sender, UnhandledExceptionReportingEventArgs e) { var dialog = new CrashReportForm(e.Error); DialogResult result = dialog.ShowDialog(); e.Cancel = result == DialogResult.Cancel; }
private bool ShowDialog(Error error) { var dialog = new CrashReportForm(error); DialogResult result = dialog.ShowDialog(); return(result == DialogResult.OK); }
private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e) { // ev.ExceptionlessClientInfo.Platform = ".NET Windows"; if (!e.IsUnhandledError) { return; } var dialog = new CrashReportForm(e.Client, e.Event); e.Cancel = dialog.ShowDialog() != DialogResult.OK; }
public static void SendReport(string exceptionMessage, int crashLocation, string[] logs, string threadName) { var crashReport = new CrashReportData { ["Application"] = "GameStudio", ["UserEmail"] = "", ["UserMessage"] = "", ["StrideVersion"] = StrideVersion.NuGetVersion, ["GameStudioVersion"] = DebugVersion.ToString(), ["ThreadName"] = string.IsNullOrEmpty(threadName) ? "" : threadName, #if DEBUG ["CrashLocation"] = crashLocation.ToString(), ["ProcessID"] = Process.GetCurrentProcess().Id.ToString() #endif }; try { // Add session-specific information in this try/catch block var gameSettingsAsset = SessionViewModel.Instance?.CurrentProject?.Package.GetGameSettingsAsset(); if (gameSettingsAsset != null) { crashReport["DefaultGraphicProfile"] = gameSettingsAsset.GetOrCreate <RenderingSettings>().DefaultGraphicsProfile.ToString(); } } catch (Exception e) { e.Ignore(); } // opened assets try { var manager = SessionViewModel.Instance?.Dialogs?.AssetEditorsManager as AssetEditorsManager; if (manager != null) { var sb = new StringBuilder(); foreach (var asset in manager.GetCurrentlyOpenedAssets()) { sb.AppendLine($"{asset.Id}:{asset.Name} ({asset.TypeDisplayName})"); } crashReport["OpenedAssets"] = sb.ToString(); } } catch (Exception e) { e.Ignore(); } // action history try { // Add session-specific information in this try/catch block var actionsViewModel = SessionViewModel.Instance?.ActionHistory; if (actionsViewModel != null) { var actions = actionsViewModel.Transactions.ToList(); var sb = new StringBuilder(); for (var i = Math.Max(0, actions.Count - 5); i < actions.Count; ++i) { ExpandAction(actions[i], sb, 4); } crashReport["LastActions"] = sb.ToString(); } } catch (Exception e) { e.Ignore(); } // transaction in progress try { // Add session-specific information in this try/catch block var actionService = SessionViewModel.Instance?.UndoRedoService; if (actionService != null && actionService.TransactionInProgress) { // FIXME: expose some readonly properties/methods from ITransactionStack or ITransaction to reduce reflection var stackField = typeof(UndoRedoService).GetField("stack", BindingFlags.Instance | BindingFlags.NonPublic); if (stackField != null) { var transactionsInProgressField = typeof(ITransactionStack).Assembly.GetType("Stride.Core.Transactions.TransactionStack")?.GetField("transactionsInProgress", BindingFlags.Instance | BindingFlags.NonPublic); if (transactionsInProgressField != null) { var stack = stackField.GetValue(actionService); var transactionsInProgress = transactionsInProgressField.GetValue(stack) as IEnumerable <IReadOnlyTransaction>; if (transactionsInProgress != null) { var sb = new StringBuilder(); sb.AppendLine("Transactions in progress:"); foreach (var transaction in transactionsInProgress) { PrintTransaction(transaction, sb, 4); } crashReport["TransactionInProgress"] = sb.ToString(); } } } } } catch (Exception e) { e.Ignore(); } crashReport["CurrentDirectory"] = Environment.CurrentDirectory; crashReport["CommandArgs"] = string.Join(" ", AppHelper.GetCommandLineArgs()); var osVersion = CrashReportUtils.GetOsVersionAndCaption(); crashReport["OsVersion"] = $"{osVersion.Key} {osVersion.Value} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}"; crashReport["ProcessorCount"] = Environment.ProcessorCount.ToString(); crashReport["Exception"] = exceptionMessage; var videoConfig = AppHelper.GetVideoConfig(); foreach (var conf in videoConfig) { crashReport.Data.Add(Tuple.Create(conf.Key, conf.Value)); } var nonFatalReport = new StringBuilder(); for (var index = 0; index < logs.Length; index++) { var log = logs[index]; nonFatalReport.AppendFormat($"{index + 1}: {log}\r\n"); } crashReport["Log"] = nonFatalReport.ToString(); // Try to anonymize reports // It also makes it easier to copy and paste paths for (var i = 0; i < crashReport.Data.Count; i++) { var data = crashReport.Data[i].Item2; data = Regex.Replace(data, Regex.Escape(Environment.GetEnvironmentVariable("USERPROFILE")), Regex.Escape("%USERPROFILE%"), RegexOptions.IgnoreCase); data = Regex.Replace(data, $@"\b{Regex.Escape(Environment.GetEnvironmentVariable("USERNAME"))}\b", Regex.Escape("%USERNAME%"), RegexOptions.IgnoreCase); crashReport.Data[i] = Tuple.Create(crashReport.Data[i].Item1, data); } var reporter = new CrashReportForm(crashReport, new ReportSettings()); var result = reporter.ShowDialog(); StrideGameStudio.MetricsClient?.CrashedSession(result == DialogResult.Yes); }