root/trunk/AprSharp/dev/src/AprArgumentException.cs

Revision 59, 3.6 kB (checked in by DenisG, 4 years ago)

[AprSharp] Cosmetic. License region.

  • Property svn:eol-style set to native
Line 
1 //  AprSharp, a wrapper library around the Apache Portable Runtime Library
2 #region Copyright (C) 2004 SOFTEC sa.
3 //
4 //  This library is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU Lesser General Public
6 //  License as published by the Free Software Foundation; either
7 //  version 2.1 of the License, or (at your option) any later version.
8 //
9 //  This library is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 //  Lesser General Public License for more details.
13 //
14 //  You should have received a copy of the GNU Lesser General Public
15 //  License along with this library; if not, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 //  Sources, support options and lastest version of the complete library
19 //  is available from:
20 //              http://www.softec.st/AprSharp
21 //             
22 //
23 //  Initial authors :
24 //              Denis Gervalle
25 //              Olivier Desaive
26 #endregion
27 //
28 using System;
29 using System.Runtime.Serialization;
30
31 namespace Softec.AprSharp
32 {
33     [Serializable]
34     public class AprArgumentException : AprException
35     {
36         const int Result = unchecked ((int)0xA0650057);
37
38         private string mParamName;
39        
40         public AprArgumentException()
41                : base ( "An invalid argument was specified." )
42         {
43             HResult = Result;
44             mParamName = null;
45         }
46
47         public AprArgumentException(string message)
48                : base ( message )
49         {
50             HResult = Result;
51             mParamName = null;
52         }
53
54         public AprArgumentException(string message, string paramName)
55                : base ( message )
56         {
57             HResult = Result;
58             this.mParamName = paramName;
59         }
60
61         public AprArgumentException(int apr_status)
62                : base ( apr_status )
63         {
64             mParamName = null;
65         }
66        
67         public AprArgumentException(int apr_status, string paramName)
68                : base ( apr_status )
69         {
70             mParamName = paramName;
71         }
72        
73         public AprArgumentException(int apr_status, Exception innerException)
74                : base ( apr_status, innerException )
75         {
76             mParamName = null;
77         }
78
79         public AprArgumentException(int apr_status, string paramName, Exception innerException)
80                : base ( apr_status, innerException )
81         {
82             mParamName = paramName;
83         }
84
85         public AprArgumentException(SerializationInfo info, StreamingContext context)
86                : base (info, context)
87         {
88             mParamName = info.GetString("ParamName");
89         }
90        
91         public virtual string ParamName
92         {
93             get
94             {
95                 return mParamName;
96             }
97         }
98        
99         public override string Message
100         {
101             get
102             {
103                 string baseMessage = base.Message;
104                 if(baseMessage == null)
105                     baseMessage = "An invalid argument was specified.";
106                
107                 if(mParamName == null)
108                     return baseMessage;
109                 else
110                     return( baseMessage + Environment.NewLine
111                             + "Parameter name: " + mParamName );
112             }
113         }
114
115         public override void GetObjectData(SerializationInfo info, StreamingContext context)
116         {
117             base.GetObjectData(info,context);
118             info.AddValue("ParamName", mParamName);
119         }                 
120     }
121 }
Note: See TracBrowser for help on using the browser.