MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:January 11 2007 8:18pm
Subject:Connector/NET commit: r548 - in branches/1.0: . TestSuite mysqlclient
View as plain text  
Modified:
   branches/1.0/CHANGES
   branches/1.0/TestSuite/ConnectionTests.cs
   branches/1.0/mysqlclient/Exception.cs
   branches/1.0/mysqlclient/MySqlError.cs
   branches/1.0/mysqlclient/Resources.Designer.cs
   branches/1.0/mysqlclient/Resources.resx
   branches/1.0/mysqlclient/nativedriver.cs
Log:
Bug #24802 Error Handling 

Fixed this by making sure the Number proper of MySqlException is set when we can't connect to the given host

Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/CHANGES	2007-01-11 20:18:19 UTC (rev 548)
@@ -18,6 +18,7 @@
     Bug #25013 Return Value parameter not found 
     Bug #22400 Nested transactions 
     Bug #25443 ExecuteScalar() hangs when more than one bad result 		
+    Bug #24802 Error Handling 
 
     Other changes
     -------------

Modified: branches/1.0/TestSuite/ConnectionTests.cs
===================================================================
--- branches/1.0/TestSuite/ConnectionTests.cs	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/TestSuite/ConnectionTests.cs	2007-01-11 20:18:19 UTC (rev 548)
@@ -330,5 +330,28 @@
             }
             suExecSQL("DELETE FROM mysql.user WHERE user='quotedUser'");
         }
+
+        /// <summary>
+        /// Bug #24802 Error Handling 
+        /// </summary>
+        [Test]
+        public void TestConnectingSocketBadHostName()
+        {
+            string connStr = "server=foobar;user id=foouser;password=;database=Test;" +
+                "pooling=false";
+            MySqlConnection c = new MySqlConnection(connStr);
+            try
+            {
+                c.Open();
+            }
+            catch (MySqlException ex)
+            {
+                Assert.AreEqual((int)MySqlErrorCode.UnableToConnectToHost, ex.Number);
+            }
+            catch (Exception e)
+            {
+                Assert.Fail(e.Message);
+            }
+        }
     }
 }

Modified: branches/1.0/mysqlclient/Exception.cs
===================================================================
--- branches/1.0/mysqlclient/Exception.cs	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/mysqlclient/Exception.cs	2007-01-11 20:18:19 UTC (rev 548)
@@ -53,6 +53,12 @@
 			this.isFatal = isFatal;
 		}
 
+        internal MySqlException(string msg, int errno, Exception inner)
+            : this(msg, inner)
+        {
+            errorCode = errno;
+        }
+
 		internal MySqlException(string msg, int errno)
 			: this(msg)
 		{

Modified: branches/1.0/mysqlclient/MySqlError.cs
===================================================================
--- branches/1.0/mysqlclient/MySqlError.cs	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/mysqlclient/MySqlError.cs	2007-01-11 20:18:19 UTC (rev 548)
@@ -113,35 +113,38 @@
 		/// The specified key was not found.
 		/// </summary>
 		KeyNotFound = 1032,
-		/*		ER_NOT_FORM_FILE 1033
-				ER_NOT_KEYFILE 1034
-				ER_OLD_KEYFILE 1035
-				ER_OPEN_AS_READONLY 1036
-				ER_OUTOFMEMORY 1037
-				ER_OUT_OF_SORTMEMORY 1038
-				ER_UNEXPECTED_EOF 1039
-				ER_CON_COUNT_ERROR 1040
-				ER_OUT_OF_RESOURCES 1041
-				ER_BAD_HOST_ERROR 1042
-				ER_HANDSHAKE_ERROR 1043
-				ER_DBACCESS_DENIED_ERROR 1044
-				ER_ACCESS_DENIED_ERROR 1045
-				ER_NO_DB_ERROR 1046
-				ER_UNKNOWN_COM_ERROR 1047
-				ER_BAD_NULL_ERROR 1048
-				ER_BAD_DB_ERROR 1049
-				ER_TABLE_EXISTS_ERROR 1050
-				ER_BAD_TABLE_ERROR 1051
-				ER_NON_UNIQ_ERROR 1052
-				ER_SERVER_SHUTDOWN 1053
-				ER_BAD_FIELD_ERROR 1054
-				ER_WRONG_FIELD_WITH_GROUP 1055
-				ER_WRONG_GROUP_FIELD 1056
-				ER_WRONG_SUM_SELECT 1057
-				ER_WRONG_VALUE_COUNT 1058
-				ER_TOO_LONG_IDENT 1059
-				ER_DUP_FIELDNAME 1060*/
-		/// <summary>
+        /*		ER_NOT_FORM_FILE 1033
+                ER_NOT_KEYFILE 1034
+                ER_OLD_KEYFILE 1035
+                ER_OPEN_AS_READONLY 1036
+                ER_OUTOFMEMORY 1037
+                ER_OUT_OF_SORTMEMORY 1038
+                ER_UNEXPECTED_EOF 1039
+                ER_CON_COUNT_ERROR 1040
+                ER_OUT_OF_RESOURCES 1041 */
+        /// <summary>
+        /// Given when the connection is unable to successfully connect to host.
+        /// </summary>
+        UnableToConnectToHost = 1042,
+/*                ER_HANDSHAKE_ERROR 1043
+                ER_DBACCESS_DENIED_ERROR 1044
+                ER_ACCESS_DENIED_ERROR 1045
+                ER_NO_DB_ERROR 1046
+                ER_UNKNOWN_COM_ERROR 1047
+                ER_BAD_NULL_ERROR 1048
+                ER_BAD_DB_ERROR 1049
+                ER_TABLE_EXISTS_ERROR 1050
+                ER_BAD_TABLE_ERROR 1051
+                ER_NON_UNIQ_ERROR 1052
+                ER_SERVER_SHUTDOWN 1053
+                ER_BAD_FIELD_ERROR 1054
+                ER_WRONG_FIELD_WITH_GROUP 1055
+                ER_WRONG_GROUP_FIELD 1056
+                ER_WRONG_SUM_SELECT 1057
+                ER_WRONG_VALUE_COUNT 1058
+                ER_TOO_LONG_IDENT 1059
+                ER_DUP_FIELDNAME 1060*/
+        /// <summary>
 		/// Duplicate Key Name
 		/// </summary>
 		DuplicateKeyName = 1061,

Modified: branches/1.0/mysqlclient/Resources.Designer.cs
===================================================================
--- branches/1.0/mysqlclient/Resources.Designer.cs	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/mysqlclient/Resources.Designer.cs	2007-01-11 20:18:19 UTC (rev 548)
@@ -394,7 +394,15 @@
                 return ResourceManager.GetString("StreamNoWrite", resourceCulture);
             }
         }
-        
+
+        internal static string UnableToConnectToHost
+        {
+            get
+            {
+                return ResourceManager.GetString("UnableToConnectToHost", resourceCulture);
+            }
+        }
+
         /// <summary>
         ///   Looks up a localized string similar to Unable to execute stored procedure &apos;{0}&apos;..
         /// </summary>

Modified: branches/1.0/mysqlclient/Resources.resx
===================================================================
--- branches/1.0/mysqlclient/Resources.resx	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/mysqlclient/Resources.resx	2007-01-11 20:18:19 UTC (rev 548)
@@ -246,4 +246,7 @@
   <data name="ReturnParameterExists" xml:space="preserve">
     <value>A return value parameter already exists in the parameter collection.</value>
   </data>
+  <data name="UnableToConnectToHost" xml:space="preserve">
+    <value>Unable to connect to any of the specified MySQL hosts.</value>
+  </data>
 </root>
\ No newline at end of file

Modified: branches/1.0/mysqlclient/nativedriver.cs
===================================================================
--- branches/1.0/mysqlclient/nativedriver.cs	2007-01-11 20:12:52 UTC (rev 547)
+++ branches/1.0/mysqlclient/nativedriver.cs	2007-01-11 20:18:19 UTC (rev 548)
@@ -156,10 +156,15 @@
 					StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName);
 					stream = sc.GetStream((uint)Settings.ConnectionTimeout);
 				}
+                if (stream == null)
+                    throw new Exception();
 			}
 			catch (Exception ex)
 			{
-				throw new MySqlException("Unable to connect to any of the specified MySQL hosts", ex);
+				throw new MySqlException(
+                    Resources.UnableToConnectToHost, 
+                    (int)MySqlErrorCode.UnableToConnectToHost,
+                    ex);
 			}
 
 

Thread
Connector/NET commit: r548 - in branches/1.0: . TestSuite mysqlclientrburnett11 Jan