2 * Firebird ADO.NET Data provider for .NET and Mono
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
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.
15 * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
16 * All Rights Reserved.
20 using System.ComponentModel;
21 using System.Security.Permissions;
22 using FirebirdSql.Data.Common;
24 namespace FirebirdSql.Data.Firebird
26 /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/overview/*'/>
30 public sealed class FbException : SystemException
34 private FbErrorCollection errors = new FbErrorCollection();
35 private int errorCode;
41 /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/property[@name="Errors"]/*'/>
43 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
45 public FbErrorCollection Errors
47 get { return this.errors; }
50 /// <include file='Doc/en_EN/FbException.xml' path='doc/class[@name="FbException"]/property[@name="ErrorCode"]/*'/>
53 get { return this.errorCode; }
60 internal FbException() : base()
64 internal FbException(string message) : base(message)
68 internal FbException(string message, IscException ex) : base(message)
70 this.errorCode = ex.ErrorCode;
72 this.Source = ex.Source;
75 this.GetIscExceptionErrors(ex);
81 System.Runtime.Serialization.SerializationInfo info,
82 System.Runtime.Serialization.StreamingContext context) : base(info, context)
84 this.errors = (FbErrorCollection)info.GetValue("errors", typeof(FbErrorCollection));
85 this.errorCode = info.GetInt32("errorCode");
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)
102 info.AddValue("errors", this.errors);
103 info.AddValue("errorCode", this.errorCode);
105 base.GetObjectData(info, context);
112 #region Internal Methods
114 internal void GetIscExceptionErrors(IscException ex)
116 foreach (IscError error in ex.Errors)
118 this.errors.Add(error.Message, error.ErrorCode);