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

Revision 1, 2.8 kB (checked in by DenisG, 3 years ago)

Initial import

  • Property svn:eol-style set to native
Line 
1 //
2 // Softec
3 //
4 // Contact: Support@softec.st
5 //
6 // Designed by Denis Gervalle and Olivier Desaive
7 // Written by Denis Gervalle
8 //
9 // Copyright 2004 by SOFTEC. All rights reserved.
10 //
11
12 using System;
13 using System.Runtime.Serialization;
14 using Softec;
15
16 namespace Softec.AprSharp
17 {
18     [Serializable]
19     public class AprArgumentException : AprException
20     {
21         const int Result = unchecked ((int)0xA0650057);
22
23         private string mParamName;
24        
25         public AprArgumentException()
26                : base ( "An invalid argument was specified." )
27         {
28             HResult = Result;
29             mParamName = null;
30         }
31
32         public AprArgumentException(string message)
33                : base ( message )
34         {
35             HResult = Result;
36             mParamName = null;
37         }
38
39         public AprArgumentException(string message, string paramName)
40                : base ( message )
41         {
42             HResult = Result;
43             this.mParamName = paramName;
44         }
45
46         public AprArgumentException(int apr_status)
47                : base ( apr_status )
48         {
49             mParamName = null;
50         }
51        
52         public AprArgumentException(int apr_status, string paramName)
53                : base ( apr_status )
54         {
55             mParamName = paramName;
56         }
57        
58         public AprArgumentException(int apr_status, Exception innerException)
59                : base ( apr_status, innerException )
60         {
61             mParamName = null;
62         }
63
64         public AprArgumentException(int apr_status, string paramName, Exception innerException)
65                : base ( apr_status, innerException )
66         {
67             mParamName = paramName;
68         }
69
70         public AprArgumentException(SerializationInfo info, StreamingContext context)
71                : base (info, context)
72         {
73             mParamName = info.GetString("ParamName");
74         }
75        
76         public virtual string ParamName
77         {
78             get
79             {
80                 return mParamName;
81             }
82         }
83        
84         public override string Message
85         {
86             get
87             {
88                 string baseMessage = base.Message;
89                 if(baseMessage == null)
90                     baseMessage = "An invalid argument was specified.";
91                
92                 if(mParamName == null)
93                     return baseMessage;
94                 else
95                     return( baseMessage + Environment.NewLine
96                             + "Parameter name: " + mParamName );
97             }
98         }
99
100         public override void GetObjectData(SerializationInfo info, StreamingContext context)
101         {
102             base.GetObjectData(info,context);
103             info.AddValue("ParamName", mParamName);
104         }                 
105     }
106 }
Note: See TracBrowser for help on using the browser.