// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using Mono.Data.Tds.Protocol;
using System;
using System.ComponentModel;
using System.Data;
using System.Runtime.Serialization;
using System.Text;
-namespace System.Data.SqlClient {
- [SerializableAttribute()]
+using Mono.Data.Tds.Protocol;
- public sealed class SqlException
-#if NET_2_0
- : DbException
-#else
- : SystemException
-#endif //NET_1_1
+namespace System.Data.SqlClient
+{
+ [Serializable]
+ public sealed class SqlException : DbException
{
+#region ReferenceSource
+ internal SqlException InternalClone() {
+ var ret = new SqlException ();
+ foreach (SqlError e in errors)
+ ret.errors.Add (e);
+ return ret;
+ }
+#endregion
+
#region Fields
- private SqlErrorCollection errors;
- private const string DEF_MESSAGE = "SQL Exception has occured.";
+ private readonly SqlErrorCollection errors;
+ private const string DEF_MESSAGE = "SQL Exception has occured.";
#endregion // Fields
#region Constructors
- internal SqlException ()
- : this (DEF_MESSAGE, null, null)
+ internal SqlException ()
+ : this (DEF_MESSAGE, null, null)
{
}
internal SqlException (string message, Exception inner, SqlError sqlError)
: base (message == null ? DEF_MESSAGE : message, inner)
{
+ HResult = -2146232060;
errors = new SqlErrorCollection ();
if (sqlError != null)
errors.Add (sqlError);
private SqlException(SerializationInfo si, StreamingContext sc)
{
- errors = (SqlErrorCollection)si.GetValue("Errors", typeof(SqlErrorCollection));
+ HResult = -2146232060;
+ errors = (SqlErrorCollection) si.GetValue ("Errors", typeof (SqlErrorCollection));
}
#endregion // Constructors
get { return Errors [0].LineNumber; }
}
-#if NET_1_0 || ONLY_1_1
- public
- override
-#else
- new
-#endif
- string Message {
+ public override string Message {
get {
if (Errors.Count == 0)
return base.Message;
result.Append (base.Message);
result.Append ("\n");
}
- for (int i=0; i < Errors.Count -1; i++) {
+ 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);
+ result.Append (Errors [Errors.Count - 1].Message);
return result.ToString ();
}
}
#region Methods
-
internal static SqlException FromTdsInternalException (TdsInternalException e)
{
- 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,
+ 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);
+ return new SqlException (null, e, sqlError);
}
public override void GetObjectData (SerializationInfo si, StreamingContext context)