Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSureshkumar T <suresh@mono-cvs.ximian.com>2005-06-29 17:31:18 +0400
committerSureshkumar T <suresh@mono-cvs.ximian.com>2005-06-29 17:31:18 +0400
commitbe58549d6ebfca7977eccc54c5489fd09ceead62 (patch)
tree2c1ab45d3a74e2d8e02d6c78f42a9f65eab6ebfc /mcs/class/System.Data/System.Data.SqlClient
parentfce8f38d47e6e16f771b4234b5b29ce48510671e (diff)
2005-06-29 Sureshkumar T <tsureshkumar@novell.com>
* Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsInternalException.cs: Add ctor for InnerException. * Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsComm.cs: Throw TdsInternalException rather than SocketException. * System.Data/System.Data.SqlClient/SqlConnection.cs: Open (): catch TdsInternalException and throw SqlException. * System.Data/System.Data.SqlClient/SqlException.cs: code re-organised to pass message as well with the exception. svn path=/trunk/mcs/; revision=46722
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlClient')
-rw-r--r--mcs/class/System.Data/System.Data.SqlClient/ChangeLog7
-rw-r--r--mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs5
-rw-r--r--mcs/class/System.Data/System.Data.SqlClient/SqlException.cs53
3 files changed, 53 insertions, 12 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
index 3f0908cd53e..393bb659e19 100644
--- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
+++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
@@ -1,3 +1,10 @@
+2005-06-29 Sureshkumar T <tsureshkumar@novell.com>
+
+ * SqlConnection.cs: Open (): catch TdsInternalException and throw
+ SqlException.
+ * SqlException.cs: code re-organised to pass message as well with
+ the exception.
+
2005-06-23 Sureshkumar T <tsureshkumar@novell.com>
* SqlConnectionStringBuilder.cs: simplified multiple keyword
diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
index e603d6671e4..a05dbb3569c 100644
--- a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
+++ b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
@@ -483,9 +483,10 @@ namespace System.Data.SqlClient {
pool = sqlConnectionPools.GetConnectionPool (connectionString, info);
tds = pool.GetConnection ();
}
- }
- catch (TdsTimeoutException e) {
+ } catch (TdsTimeoutException e) {
throw SqlException.FromTdsInternalException ((TdsInternalException) e);
+ }catch (TdsInternalException e) {
+ throw SqlException.FromTdsInternalException (e);
}
tds.TdsErrorMessage += new TdsInternalErrorMessageEventHandler (ErrorHandler);
diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
index 6a34ed752fa..2dd47a74360 100644
--- a/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
+++ b/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
@@ -54,21 +54,37 @@ namespace System.Data.SqlClient {
#region Fields
private SqlErrorCollection errors;
+ private const string DEF_MESSAGE = "SQL Exception has occured.";
#endregion // Fields
#region Constructors
internal SqlException ()
- : base ("a SQL Exception has occurred.")
+ : this (DEF_MESSAGE, null, null)
{
- errors = new SqlErrorCollection();
+ }
+
+ internal SqlException (string message, Exception inner)
+ : this (message, inner, null)
+ {
+ }
+
+ internal SqlException (string message, Exception inner, SqlError sqlError)
+ : base (message == null ? DEF_MESSAGE : message, inner)
+ {
+ errors = new SqlErrorCollection ();
+ if (sqlError != null)
+ errors.Add (sqlError);
}
internal SqlException (byte theClass, int lineNumber, string message, int number, string procedure, string server, string source, byte state)
- : base (message)
+ : this (message,
+ null,
+ new SqlError (theClass, lineNumber, message,
+ number, procedure, server, source,
+ state))
{
- errors = new SqlErrorCollection (theClass, lineNumber, message, number, procedure, server, source, state);
}
private SqlException(SerializationInfo si, StreamingContext sc)
@@ -94,13 +110,20 @@ namespace System.Data.SqlClient {
}
public override string Message {
- get {
+ get {
+ if (Errors.Count == 0)
+ return base.Message;
StringBuilder result = new StringBuilder ();
- foreach (SqlError error in Errors) {
- if (result.Length > 0)
- result.Append ('\n');
- result.Append (error.Message);
+ if (base.Message != DEF_MESSAGE) {
+ result.Append (base.Message);
+ result.Append ("\n");
}
+ for (int i=0; i < Errors.Count -1; i++) {
+ result.Append (Errors [i].Message);
+ result.Append ("\n");
+ }
+ if (Errors.Count > 0)
+ result.Append (Errors [Errors.Count - 1].Message);
return result.ToString ();
}
}
@@ -129,9 +152,19 @@ namespace System.Data.SqlClient {
#region Methods
+
internal static SqlException FromTdsInternalException (TdsInternalException e)
{
- return new SqlException (e.Class, e.LineNumber, e.Message, e.Number, e.Procedure, e.Server, "Mono SqlClient Data Provider", e.State);
+ return FromTdsInternalException (null, e);
+ }
+
+ internal static SqlException FromTdsInternalException (string message,
+ TdsInternalException e)
+ {
+ SqlError sqlError = new SqlError (e.Class, e.LineNumber, e.Message,
+ e.Number, e.Procedure, e.Server,
+ "Mono SqlClient Data Provider", e.State);
+ return new SqlException (message, e, sqlError);
}
public override void GetObjectData (SerializationInfo si, StreamingContext context)