/// <summary> /// A method to deal with unhandle exceptions. Executes right before Revit crashes. /// Dynamo is still valid at this time, but further work may cause corruption. Here, /// we run the ExitCommand, allowing the user to save all of their work. Then, we send them /// to the issues page on Github. /// </summary> /// <param name="sender"></param> /// <param name="args">Info about the exception</param> private void DispatcherOnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs args) { // only handle a single crash per Dynamo sesh, this should be reset in the initial command if (handledCrash) { args.Handled = true; return; } handledCrash = true; var exceptionMessage = args.Exception.Message; var stackTrace = args.Exception.StackTrace; var prompt = new CrashPrompt(exceptionMessage + "\n\n" + stackTrace); prompt.ShowDialog(); try { DynamoLogger.Instance.Log("Dynamo Unhandled Exception"); DynamoLogger.Instance.Log(exceptionMessage); } catch { } try { dynamoController.DynamoViewModel.ExitCommand.Execute(false); // don't allow cancellation dynamoController.DynamoViewModel.ReportABugCommand.Execute(); } catch { } finally { args.Handled = true; } }
void Controller_RequestsCrashPrompt(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { var prompt = new CrashPrompt(e.Exception.Message + "\n\n" + e.Exception.StackTrace); prompt.ShowDialog(); }
void Controller_RequestsCrashPrompt(object sender, CrashPromptArgs args) { var prompt = new CrashPrompt(args); prompt.ShowDialog(); }