Remove some deprecated libraries
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Firebird / FbException.cs
1 /*
2  *      Firebird ADO.NET Data provider for .NET and Mono 
3  * 
4  *         The contents of this file are subject to the Initial 
5  *         Developer's Public License Version 1.0 (the "License"); 
6  *         you may not use this file except in compliance with the 
7  *         License. You may obtain a copy of the License at 
8  *         http://www.firebirdsql.org/index.php?op=doc&id=idpl
9  *
10  *         Software distributed under the License is distributed on 
11  *         an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
12  *         express or implied. See the License for the specific 
13  *         language governing rights and limitations under the License.
14  * 
15  *      Copyright (c) 2002, 2005 Carlos Guzman Alvarez
16  *      All Rights Reserved.
17  */
18
19 using System;
20 using System.ComponentModel;
21 using System.Security.Permissions;
22 using FirebirdSql.Data.Common;
23
24 namespace FirebirdSql.Data.Firebird
25 {
26         /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/overview/*'/>
27 #if     (!NETCF)
28         [Serializable]
29 #endif
30         public sealed class FbException : SystemException
31         {
32                 #region Fields
33
34                 private FbErrorCollection errors = new FbErrorCollection();
35                 private int errorCode;
36
37                 #endregion
38
39                 #region Properties
40
41                 /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/property[@name="Errors"]/*'/>
42 #if     (!NETCF)
43                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
44 #endif
45                 public FbErrorCollection Errors
46                 {
47                         get { return this.errors; }
48                 }
49
50                 /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/property[@name="ErrorCode"]/*'/>
51                 public int ErrorCode
52                 {
53                         get { return this.errorCode; }
54                 }
55
56                 #endregion
57
58                 #region Constructors
59
60                 internal FbException() : base()
61                 {
62                 }
63
64                 internal FbException(string message) : base(message)
65                 {
66                 }
67
68                 internal FbException(string message, IscException ex) : base(message)
69                 {
70                         this.errorCode = ex.ErrorCode;
71 #if     (!NETCF)
72                         this.Source = ex.Source;
73 #endif
74
75                         this.GetIscExceptionErrors(ex);
76                 }
77
78 #if     (!NETCF)
79
80                 internal FbException(
81             System.Runtime.Serialization.SerializationInfo info, 
82             System.Runtime.Serialization.StreamingContext context) : base(info, context)
83                 {
84                         this.errors = (FbErrorCollection)info.GetValue("errors", typeof(FbErrorCollection));
85                         this.errorCode = info.GetInt32("errorCode");
86                 }
87
88 #endif
89
90                 #endregion
91
92                 #region Methods
93
94 #if     (!NETCF)
95
96                 /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/method[@name="GetObjectData(SerializationInfo, StreamingContext)"]/*'/>
97                 [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
98                 public override void GetObjectData(
99             System.Runtime.Serialization.SerializationInfo info, 
100             System.Runtime.Serialization.StreamingContext context)
101                 {
102                         info.AddValue("errors", this.errors);
103                         info.AddValue("errorCode", this.errorCode);
104
105                         base.GetObjectData(info, context);
106                 }
107
108 #endif
109
110                 #endregion
111
112                 #region Internal Methods
113
114                 internal void GetIscExceptionErrors(IscException ex)
115                 {
116                         foreach (IscError error in ex.Errors)
117                         {
118                                 this.errors.Add(error.Message, error.ErrorCode);
119                         }
120                 }
121
122                 #endregion
123         }
124 }