Modified:
branches/5.0/CHANGES
branches/5.0/Driver/Source/Exception.cs
branches/5.0/Driver/Source/MySqlError.cs
branches/5.0/Driver/Source/NativeDriver.cs
branches/5.0/Driver/Source/Resources.Designer.cs
branches/5.0/Driver/Source/Resources.resx
branches/5.0/TestSuite/ConnectionTests.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/5.0/CHANGES
===================================================================
--- branches/5.0/CHANGES 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/CHANGES 2007-01-11 20:12:52 UTC (rev 547)
@@ -3,6 +3,7 @@
Bugs fixed
----------
Bug #25443 ExecuteScalar() hangs when more than one bad result
+ Bug #24802 Error Handling
Other changes
-------------
Modified: branches/5.0/Driver/Source/Exception.cs
===================================================================
--- branches/5.0/Driver/Source/Exception.cs 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/Driver/Source/Exception.cs 2007-01-11 20:12:52 UTC (rev 547)
@@ -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)
{
errorCode = errno;
Modified: branches/5.0/Driver/Source/MySqlError.cs
===================================================================
--- branches/5.0/Driver/Source/MySqlError.cs 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/Driver/Source/MySqlError.cs 2007-01-11 20:12:52 UTC (rev 547)
@@ -113,34 +113,37 @@
/// 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*/
+ /* 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>
Modified: branches/5.0/Driver/Source/NativeDriver.cs
===================================================================
--- branches/5.0/Driver/Source/NativeDriver.cs 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/Driver/Source/NativeDriver.cs 2007-01-11 20:12:52 UTC (rev 547)
@@ -187,10 +187,15 @@
#if !PocketPC
}
#endif
+ if (baseStream == 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);
}
if (baseStream == null)
Modified: branches/5.0/Driver/Source/Resources.Designer.cs
===================================================================
--- branches/5.0/Driver/Source/Resources.Designer.cs 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/Driver/Source/Resources.Designer.cs 2007-01-11 20:12:52 UTC (rev 547)
@@ -556,6 +556,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Unable to connect to any of the
specified MySQL hosts..
+ /// </summary>
+ internal static string UnableToConnectToHost {
+ get {
+ return ResourceManager.GetString("UnableToConnectToHost",
resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Unable to execute stored procedure
'{0}'..
/// </summary>
internal static string UnableToExecuteSP {
Modified: branches/5.0/Driver/Source/Resources.resx
===================================================================
--- branches/5.0/Driver/Source/Resources.resx 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/Driver/Source/Resources.resx 2007-01-11 20:12:52 UTC (rev 547)
@@ -297,4 +297,7 @@
<data name="WrongParameterName" xml:space="preserve">
<value>Parameter '{0}' is not found but a parameter with the name '{1}' is
found. Parameter names must include the leading parameter marker.</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/5.0/TestSuite/ConnectionTests.cs
===================================================================
--- branches/5.0/TestSuite/ConnectionTests.cs 2007-01-11 16:58:18 UTC (rev 546)
+++ branches/5.0/TestSuite/ConnectionTests.cs 2007-01-11 20:12:52 UTC (rev 547)
@@ -342,5 +342,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);
+ }
+ }
+ }
}
| Thread |
|---|
| • Connector/NET commit: r547 - in branches/5.0: . Driver/Source TestSuite | rburnett | 11 Jan |