blob: de2d775c8478ba9413caa6018aed4b4e8904aaff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*=============================================================================
**
**
**
** Purpose: Exception class for invalid arguments to a method.
**
**
=============================================================================*/
using System.Globalization;
using System.Runtime.Serialization;
namespace System
{
// The ArgumentException is thrown when an argument does not meet
// the contract of the method. Ideally it should give a meaningful error
// message describing what was wrong and which parameter is incorrect.
//
public class ArgumentException : SystemException
{
private String _paramName;
// Creates a new ArgumentException with its message
// string set to the empty string.
public ArgumentException()
: base(SR.Arg_ArgumentException)
{
HResult = __HResults.COR_E_ARGUMENT;
}
// Creates a new ArgumentException with its message
// string set to message.
//
public ArgumentException(String message)
: base(message)
{
HResult = __HResults.COR_E_ARGUMENT;
}
public ArgumentException(String message, Exception innerException)
: base(message, innerException)
{
HResult = __HResults.COR_E_ARGUMENT;
}
public ArgumentException(String message, String paramName, Exception innerException)
: base(message, innerException)
{
_paramName = paramName;
HResult = __HResults.COR_E_ARGUMENT;
}
public ArgumentException(String message, String paramName)
: base(message)
{
_paramName = paramName;
HResult = __HResults.COR_E_ARGUMENT;
}
protected ArgumentException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
throw new PlatformNotSupportedException();
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
public override String Message
{
get
{
String s = base.Message;
if (!String.IsNullOrEmpty(_paramName))
{
String resourceString = SR.Format(SR.Arg_ParamName_Name, _paramName);
return s + Environment.NewLine + resourceString;
}
else
return s;
}
}
public virtual String ParamName
{
get { return _paramName; }
}
}
}
|