예제 #1
0
        // Code to execute on Unhandled Exceptions
        private static void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            try
            {
                LogInstance.LogCritical("Unhandled exception: {0}", e.ExceptionObject);

                if (Debugger.IsAttached)
                {
                    // An unhandled exception has occurred; break into the debugger
                    Debugger.Break();
                }

                // don't navigate to an error view as that is awkward and doesn't play well with navigation
                // don't show a MessageBox either as that isn't customizable

                DispatchUtil.SafeDispatch(() =>
                {
                    if (e.ExceptionObject is DataFormatReadException)
                    {
                        MessageBox.Show(e.ExceptionObject.Message, "Unexpected Data Returned", MessageBoxButton.OK);
                        var coreData = IoC.Get<ICoreData>();
                        var duringStartup = !coreData.IsLoaded;
                        if (duringStartup) ExitApp();
                        return;
                    }

                    var errorWin = new ErrorWindow(e.ExceptionObject,
                    "An unexpected error has occurred. Please click Send to report the error details.") { Title = "Unexpected Error" };
                    errorWin.Show();
                });

                e.Handled = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                e.Handled = false;
                //Quit();
            }
        }
예제 #2
0
 private static void AfterErrorMessageReceived(ErrorMessage errorMessage)
 {
     DispatchUtil.SafeDispatch(() =>
     {
         var friendlyMsg = !string.IsNullOrEmpty(errorMessage.FriendlyError) ? errorMessage.FriendlyError : "Aw snap. An error occurred.";
         var errorWin = new ErrorWindow(errorMessage.Error, friendlyMsg)
         {
             Title = errorMessage.Title
         };
         errorWin.Show();
     });
 }