(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Data.PostgreSqlClient / Mono.Data.PostgreSqlClient / PgSqlException.cs
blob8e9acd5eb61807eacfc3b2b4c4c7787c8533393f
1 //
2 // Mono.Data.PostgreSqlClient.PgSqlException.cs
3 //
4 // Author:
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Daniel Morgan (danmorg@sc.rr.com)
7 //
8 // (C) Ximian, Inc
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.Data;
33 using System.Runtime.Serialization;
35 namespace Mono.Data.PostgreSqlClient
37 /// <summary>
38 /// Exceptions, as returned by SQL databases.
39 /// </summary>
40 public sealed class PgSqlException : SystemException
42 private PgSqlErrorCollection errors;
44 internal PgSqlException()
45 : base("a SQL Exception has occurred") {
46 errors = new PgSqlErrorCollection();
49 internal PgSqlException(byte theClass, int lineNumber,
50 string message, int number, string procedure,
51 string server, string source, byte state)
52 : base(message) {
54 errors = new PgSqlErrorCollection (theClass,
55 lineNumber, message,
56 number, procedure,
57 server, source, state);
60 #region Properties
62 [MonoTODO]
63 public byte Class {
64 get {
65 if(errors.Count == 0)
66 return 0; // FIXME: throw exception here?
67 else
68 return errors[0].Class;
71 set {
72 errors[0].SetClass(value);
76 [MonoTODO]
77 public PgSqlErrorCollection Errors {
78 get {
79 return errors;
82 set {
83 errors = value;
87 [MonoTODO]
88 public int LineNumber {
89 get {
90 if(errors.Count == 0)
91 return 0; // FIXME: throw exception here?
92 return errors[0].LineNumber;
95 set {
96 errors[0].SetLineNumber(value);
100 [MonoTODO]
101 public override string Message {
102 get {
103 if(errors.Count == 0)
104 return ""; // FIXME: throw exception?
105 else {
106 String msg = "";
107 int i = 0;
109 for(i = 0; i < errors.Count - 1; i++) {
110 msg = msg + errors[i].Message + "\n";
112 msg = msg + errors[i].Message;
114 return msg;
119 [MonoTODO]
120 public int Number {
121 get {
122 if(errors.Count == 0)
123 return 0; // FIXME: throw exception?
124 else
125 return errors[0].Number;
128 set {
129 errors[0].SetNumber(value);
133 [MonoTODO]
134 public string Procedure {
135 get {
136 if(errors.Count == 0)
137 return ""; // FIXME: throw exception?
138 else
139 return errors[0].Procedure;
142 set {
143 errors[0].SetProcedure(value);
147 [MonoTODO]
148 public string Server {
149 get {
150 if(errors.Count == 0)
151 return ""; // FIXME: throw exception?
152 else
153 return errors[0].Server;
156 set {
157 errors[0].SetServer(value);
161 [MonoTODO]
162 public override string Source {
163 get {
164 if(errors.Count == 0)
165 return ""; // FIXME: throw exception?
166 else
167 return errors[0].Source;
170 set {
171 errors[0].SetSource(value);
175 [MonoTODO]
176 public byte State {
177 get {
178 if(errors.Count == 0)
179 return 0; // FIXME: throw exception?
180 else
181 return errors[0].State;
184 set {
185 errors[0].SetState(value);
189 #endregion // Properties
191 #region Methods
193 [MonoTODO]
194 public override void GetObjectData(SerializationInfo si,
195 StreamingContext context) {
196 // FIXME: to do
199 // [Serializable]
200 // [ClassInterface(ClassInterfaceType.AutoDual)]
201 public override string ToString() {
202 String toStr = "";
203 for (int i = 0; i < errors.Count; i++) {
204 toStr = toStr + errors[i].ToString() + "\n";
206 return toStr;
209 internal void Add(byte theClass, int lineNumber,
210 string message, int number, string procedure,
211 string server, string source, byte state) {
213 errors.Add (theClass, lineNumber, message,
214 number, procedure,
215 server, source, state);
218 [MonoTODO]
219 ~PgSqlException() {
220 // FIXME: destructor to release resources
223 #endregion // Methods