Example #1
0
 public static DialogResult ShowErrorDialog(string friendlyMessage, Exception ex, bool allowContinue)
 {
     var lang = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
     var dialog = new ErrorWindow(lang)
     {
         ShowContinue = allowContinue,
         Message = friendlyMessage,
         Error = ex
     };
     var dialogResult = dialog.ShowDialog();
     if (dialogResult == DialogResult.Abort)
     {
         Environment.Exit(1);
     }
     return dialogResult;
 }
Example #2
0
        public static DialogResult ShowErrorDialog(string friendlyMessage, Exception ex, bool allowContinue)
        {
            var lang = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;

            using var dialog = new ErrorWindow(lang)
                  {
                      ShowContinue = allowContinue,
                      Message      = friendlyMessage,
                      Error        = ex
                  };
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.Abort)
            {
                Environment.Exit(1);
            }
            return(dialogResult);
        }
Example #3
0
        // Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution.
        private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
        {
            DialogResult result = DialogResult.Cancel;

            try
            {
                result = ErrorWindow.ShowErrorDialog("An unhandled exception has occurred.\nYou can continue running PKHeX, but please report this error.", t.Exception, true);
            }
            catch (Exception reportingException)
            {
                HandleReportingException(t.Exception, reportingException);
            }

            // Exits the program when the user clicks Abort.
            if (result == DialogResult.Abort)
            {
                Application.Exit();
            }
        }
Example #4
0
        // Handle the UI exceptions by showing a dialog box, and asking the user whether
        // or not they wish to abort execution.
        // NOTE: This exception cannot be kept from terminating the application - it can only
        // log the event, and inform the user about it.
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = e.ExceptionObject as Exception;

            try
            {
                if (ex != null)
                {
                    ErrorWindow.ShowErrorDialog("An unhandled exception has occurred.\nPKHeX must now close.", ex, false);
                }
                else
                {
                    Error("A fatal non-UI error has occurred in PKHeX, and the details could not be displayed.  Please report this to the author.");
                }
            }
            catch (Exception reportingException)
            {
                HandleReportingException(ex, reportingException);
            }
        }
Example #5
0
 // Handle the UI exceptions by showing a dialog box, and asking the user whether
 // or not they wish to abort execution.
 // NOTE: This exception cannot be kept from terminating the application - it can only
 // log the event, and inform the user about it.
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     try
     {
         var ex = (Exception)e.ExceptionObject;
         // Todo: make this translatable
         ErrorWindow.ShowErrorDialog("An unhandled exception has occurred.\nPKHeX must now close.", ex, false);
     }
     catch
     {
         try
         {
             // Todo: make this translatable
             MessageBox.Show("A fatal non-UI error has occurred in PKHeX, and the details could not be displayed.  Please report this to the author.", "PKHeX Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
         finally
         {
             Application.Exit();
         }
     }
 }
Example #6
0
 /// <summary>
 /// Displays a dialog showing the details of an error.
 /// </summary>
 /// <param name="friendlyMessage">User-friendly message about the error.</param>
 /// <param name="exception">Instance of the error's <see cref="Exception"/>.</param>
 /// <returns>The <see cref="DialogResult"/> associated with the dialog.</returns>
 internal static DialogResult Error(string friendlyMessage, Exception exception)
 {
     System.Media.SystemSounds.Exclamation.Play();
     return(ErrorWindow.ShowErrorDialog(friendlyMessage, exception, true));
 }