diff --git a/src/DynamoCoreWpf/Utilities/CrashReportTool.cs b/src/DynamoCoreWpf/Utilities/CrashReportTool.cs index 40f742d1a25..a44e2062d67 100644 --- a/src/DynamoCoreWpf/Utilities/CrashReportTool.cs +++ b/src/DynamoCoreWpf/Utilities/CrashReportTool.cs @@ -177,10 +177,11 @@ internal static bool ShowCrashErrorReportWindow(DynamoViewModel viewModel, Crash DynamoModel model = viewModel?.Model; - string cerToolDir = !string.IsNullOrEmpty(model.CERLocation) ? - model.CERLocation : FindCERToolInInstallLocations(); + string cerToolDir = !string.IsNullOrEmpty(model?.CERLocation) ? + model?.CERLocation : FindCERToolInInstallLocations(); + + var cerToolPath = !string.IsNullOrEmpty(cerToolDir) ? Path.Combine(cerToolDir, CERDllName) : string.Empty; - var cerToolPath = Path.Combine(cerToolDir, CERDllName); if (string.IsNullOrEmpty(cerToolPath) || !File.Exists(cerToolPath)) { model?.Logger?.LogError($"The CER tool was not found at location {cerToolPath}"); @@ -199,30 +200,57 @@ internal static bool ShowCrashErrorReportWindow(DynamoViewModel viewModel, Crash { string logFile = Path.Combine(cerDir.FullName, "DynamoLog.log"); - File.Copy(model.Logger.LogPath, logFile); - // might be usefull to dump all loaded Packages into - // the log at this point. - filesToSend.Add(logFile); + if(File.Exists(model.Logger.LogPath)) + { + File.Copy(model.Logger.LogPath, logFile); + filesToSend.Add(logFile); + } + else + { + model?.Logger?.LogError($"Failed to add DynamoLog.log to CER with the following error : {model.Logger.LogPath} Not Found"); + } } if (args.SendSettingsFile && model != null) { string settingsFile = Path.Combine(cerDir.FullName, "DynamoSettings.xml"); - File.Copy(model.PathManager.PreferenceFilePath, settingsFile); - filesToSend.Add(settingsFile); + if (File.Exists(model.PathManager.PreferenceFilePath)) + { + File.Copy(model.PathManager.PreferenceFilePath, settingsFile); + + filesToSend.Add(settingsFile); + } + else + { + model?.Logger?.LogError($"Failed to add DynamoSettings.xml to CER with the following error : {model.PathManager.PreferenceFilePath} Not Found"); + } } if (args.HasDetails()) { var stackTracePath = Path.Combine(cerDir.FullName, "StackTrace.log"); - File.WriteAllText(stackTracePath, args.Details); - filesToSend.Add(stackTracePath); + try + { + File.WriteAllText(stackTracePath, args.Details); + filesToSend.Add(stackTracePath); + } + catch (Exception ex) + { + model?.Logger?.LogError($"Failed to add StackTrace.log to CER with the following error : {ex.Message}"); + } } if (args.SendRecordedCommands && viewModel != null) { - filesToSend.Add(viewModel.DumpRecordedCommands()); + try + { + filesToSend.Add(viewModel.DumpRecordedCommands()); + } + catch (Exception ex) + { + model?.Logger?.LogError($"Failed to add recorded commands to CER with the following error : {ex.Message}"); + } } string appConfig = ""; @@ -234,9 +262,23 @@ internal static bool ShowCrashErrorReportWindow(DynamoViewModel viewModel, Crash $"session_start_count=\"0\" session_clean_close_count=\"0\" current_session_length=\"0\" />"; } - string dynName = viewModel?.Model.CurrentWorkspace.Name; + string dynName = model?.CurrentWorkspace.Name; + + var miniDumpFilePath = string.Empty; + try + { + miniDumpFilePath = CreateMiniDumpFile(cerDir.FullName); + } + catch (Exception ex) + { + model?.Logger?.LogError($"Failed to generate minidump file for CER due to the following error : {ex.Message}"); + } + + if (string.IsNullOrEmpty(miniDumpFilePath)) + { + return false; + } - var miniDumpFilePath = CreateMiniDumpFile(cerDir.FullName); var upiConfigFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "upiconfig.xml"); using (var cerDLL = new CerDLL(cerToolPath))