2 // System.Data.ProviderBase.AbstractDbException
\r
5 // Konstantin Triger <kostat@mainsoft.com>
\r
6 // Boris Kirzner <borisk@mainsoft.com>
\r
8 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
\r
12 // Permission is hereby granted, free of charge, to any person obtaining
\r
13 // a copy of this software and associated documentation files (the
\r
14 // "Software"), to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify, merge, publish,
\r
16 // distribute, sublicense, and/or sell copies of the Software, and to
\r
17 // permit persons to whom the Software is furnished to do so, subject to
\r
18 // the following conditions:
\r
20 // The above copyright notice and this permission notice shall be
\r
21 // included in all copies or substantial portions of the Software.
\r
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
33 namespace System.Data.ProviderBase {
\r
37 using System.Data.Common;
\r
40 * CURRENT LIMITATIONS
\r
41 * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc)
\r
43 * 2. Method "void GetObjectData(...,...)" is not supported (serialization)
\r
46 public abstract class AbstractDbException :
\r
50 System.SystemException
\r
53 protected SQLException _cause;
\r
54 protected AbstractDBConnection _connection;
\r
56 protected AbstractDbException(Exception cause, AbstractDBConnection connection) : base(cause.Message, cause) {
\r
57 _connection = connection;
\r
60 protected AbstractDbException(SQLException cause, AbstractDBConnection connection) : this(String.Empty, cause, connection) {}
\r
62 protected AbstractDbException(string message, SQLException cause, AbstractDBConnection connection) : base(message, cause) {
\r
63 _connection = connection;
\r
67 abstract protected AbstractDbErrorCollection DbErrors { get; }
\r
70 * Gets the error code of the error.
\r
71 * @return The error code of the error.
\r
73 protected int DbErrorCode {
\r
75 return _cause != null ? _cause.getErrorCode() : 0;
\r
81 * Gets the name of the OLE DB provider that generated the error.
\r
82 * @return the name of the OLE DB provider that generated the error.
\r
84 public override String Source {
\r
86 return _connection != null ? _connection.JdbcProvider : null;
\r
90 public override string Message {
\r
92 StringBuilder sb = new StringBuilder();
\r
93 string message = base.Message;
\r
94 bool addNewLine = false;
\r
95 if (message != null && message.Length > 0) {
\r
100 foreach (AbstractDbError err in DbErrors) {
\r
102 sb.Append(Environment.NewLine);
\r
105 sb.Append(err.DbMessage);
\r
107 return sb.ToString();
\r