[mapguide-commits] r5613 - in trunk/Tools/Maestro: Maestro.Login OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Mar 9 02:23:41 EST 2011


Author: jng
Date: 2011-03-08 23:23:41 -0800 (Tue, 08 Mar 2011)
New Revision: 5613

Modified:
   trunk/Tools/Maestro/Maestro.Login/LoginDialog.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
Log:
Clean up login error messages. No need to have so many nested exceptions when we know the types of exceptions that are thrown

Modified: trunk/Tools/Maestro/Maestro.Login/LoginDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Login/LoginDialog.cs	2011-03-09 06:02:47 UTC (rev 5612)
+++ trunk/Tools/Maestro/Maestro.Login/LoginDialog.cs	2011-03-09 07:23:41 UTC (rev 5613)
@@ -26,6 +26,7 @@
 using System.Windows.Forms;
 using OSGeo.MapGuide.MaestroAPI;
 using OSGeo.MapGuide.MaestroAPI.Exceptions;
+using System.Reflection;
 
 namespace Maestro.Login
 {
@@ -179,7 +180,7 @@
             using (new WaitCursor(this))
             {
                 try
-				{
+                {
                     PreferedSite ps = null;
 
                     if (_selectedIndex == 0) //HTTP
@@ -250,7 +251,7 @@
                         }
                         catch (Exception)
                         {
-                            
+
                         }
                     }
                     else //Native
@@ -265,17 +266,23 @@
 
                     _conn.AutoRestartSession = true;
 
-                    
-					
-					this.DialogResult = DialogResult.OK;
-					this.Close();
 
-				}
-				catch (Exception ex)
-				{
+
+                    this.DialogResult = DialogResult.OK;
+                    this.Close();
+
+                }
+                catch (TargetInvocationException ex) 
+                {
+                    //We don't care about the outer exception
+                    string msg = ex.InnerException.Message;
+                    MessageBox.Show(this, string.Format(Strings.FormLogin.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
+                catch (Exception ex)
+                {
                     string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
-					MessageBox.Show(this, string.Format(Strings.FormLogin.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
-				}
+                    MessageBox.Show(this, string.Format(Strings.FormLogin.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+                }
             }
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2011-03-09 06:02:47 UTC (rev 5612)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs	2011-03-09 07:23:41 UTC (rev 5613)
@@ -1106,10 +1106,15 @@
 
 					if (!ok)
 					{
-						if (throwException) //Report original error
-							throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + NestedExceptionMessageProcessor.GetFullMessage(ex), ex);
-						else
-							return false;
+                        if (throwException) //Report original error
+                        {
+                            if (ex is WebException) //These exceptions, we just want the underlying message. No need for 50 bajillion nested exceptions
+                                throw;
+                            else //We don't know what this could be so grab everything
+                                throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + ex.Message, ex);
+                        }
+                        else
+                            return false;
 					}
 				}
 



More information about the mapguide-commits mailing list