singrdk/base/Applications/Runtime/Full/System/ArgumentException.cs

90 lines
3.0 KiB
C#
Raw Normal View History

2008-03-05 09:52:00 -05:00
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
2008-11-17 18:29:00 -05:00
//=============================================================================
//
// Class: ArgumentException
//
// Purpose: Exception class for invalid arguments to a method.
//
//=============================================================================
2008-03-05 09:52:00 -05:00
2008-11-17 18:29:00 -05:00
namespace System
{
2008-03-05 09:52:00 -05:00
using 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.
//
//| <include path='docs/doc[@for="ArgumentException"]/*' />
public class ArgumentException : SystemException {
private String m_paramName;
// Creates a new ArgumentException with its message
// string set to the empty string.
//| <include path='docs/doc[@for="ArgumentException.ArgumentException"]/*' />
public ArgumentException()
: base("Arg_ArgumentException") {
}
// Creates a new ArgumentException with its message
// string set to message.
//
//| <include path='docs/doc[@for="ArgumentException.ArgumentException1"]/*' />
public ArgumentException(String message)
: base(message) {
}
//| <include path='docs/doc[@for="ArgumentException.ArgumentException2"]/*' />
public ArgumentException(String message, Exception innerException)
: base(message, innerException) {
}
//| <include path='docs/doc[@for="ArgumentException.ArgumentException3"]/*' />
public ArgumentException(String message, String paramName, Exception innerException)
: base(message, innerException) {
m_paramName = paramName;
}
//| <include path='docs/doc[@for="ArgumentException.ArgumentException4"]/*' />
public ArgumentException(String message, String paramName)
: base (message) {
m_paramName = paramName;
}
//| <include path='docs/doc[@for="ArgumentException.Message"]/*' />
public override String Message
{
get {
String s = base.Message;
2008-11-17 18:29:00 -05:00
if (!((m_paramName == null) ||
2008-03-05 09:52:00 -05:00
(m_paramName.Length == 0)) )
return s + Environment.NewLine + String.Format("{0}", m_paramName);
else
return s;
}
}
2008-11-17 18:29:00 -05:00
//
//public String ToString()
//{
// String s = super.ToString();
// if (m_paramName != null)
// return s + "Parameter name: "+m_paramName+"\tActual value: "+(m_actualValue==null ? "<null>" : m_actualValue.ToString());
// else
// return s;
//}
//
2008-03-05 09:52:00 -05:00
//| <include path='docs/doc[@for="ArgumentException.ParamName"]/*' />
public virtual String ParamName {
get { return m_paramName; }
}
}
}