2 * Copyright (c) 2002-2004 Mainsoft Corporation.
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a
\r
5 * copy of this software and associated documentation files (the "Software"),
\r
6 * to deal in the Software without restriction, including without limitation
\r
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
\r
8 * and/or sell copies of the Software, and to permit persons to whom the
\r
9 * Software is furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
\r
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
\r
20 * DEALINGS IN THE SOFTWARE.
\r
24 namespace System.Data.ProviderBase {
\r
28 using System.Data.Common;
\r
31 * CURRENT LIMITATIONS
\r
32 * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc)
\r
34 * 2. Method "void GetObjectData(...,...)" is not supported (serialization)
\r
37 public abstract class AbstractDbException : System.SystemException {
\r
38 protected SQLException _cause;
\r
39 protected AbstractDBConnection _connection;
\r
41 protected AbstractDbException(Exception cause, AbstractDBConnection connection) : base(cause.Message, cause) {
\r
42 _connection = connection;
\r
45 protected AbstractDbException(SQLException cause, AbstractDBConnection connection) : this(String.Empty, cause, connection) {}
\r
47 protected AbstractDbException(string message, SQLException cause, AbstractDBConnection connection) : base(message, cause) {
\r
48 _connection = connection;
\r
52 abstract protected AbstractDbErrorCollection DbErrors { get; }
\r
55 * Gets the error code of the error.
\r
56 * @return The error code of the error.
\r
58 protected int DbErrorCode {
\r
60 return _cause != null ? _cause.getErrorCode() : 0;
\r
66 * Gets the name of the OLE DB provider that generated the error.
\r
67 * @return the name of the OLE DB provider that generated the error.
\r
69 public override String Source {
\r
71 return _connection != null ? _connection.JdbcProvider : null;
\r
75 public override string Message {
\r
77 StringBuilder sb = new StringBuilder();
\r
78 string message = base.Message;
\r
79 bool addNewLine = false;
\r
80 if (message != null && message.Length > 0) {
\r
85 foreach (AbstractDbError err in DbErrors) {
\r
87 sb.Append(Environment.NewLine);
\r
90 sb.Append(err.DbMessage);
\r
92 return sb.ToString();
\r