Constructors: NewArgumentException

NewArgumentException

Creates a new ArgumentException object.



 Public Function NewArgumentException(
	  ByVal Message As String,
	  Optional ByVal ParamName As String,
	  Optional ByVal InnerException As Exception ) As ArgumentException

Parameters

Message
[ByVal] String. A human-readable message explaining the exception.
ParamName
[ByVal] Optional. String. The parameter that caused the exception.
InnerException
[ByVal] Optional. Exception. An exception that caused this exception.

Return Values

ArgumentException -  A fully created ArgumentException object.

Remarks

When throwing an ArgumentException a meaningful error message describing the invalid argument, the name of the argument, as well as the expected range of values for the argument should be defined.

Example

 ' Throws a default ArgumentException object
 Throw New ArgumentException

 ' Throws an ArgumentException with a custom message and parameter name
 Throw Cor.NewArgumentException("Your argument is wrong.", "MyParam")

 ' Throws an ArgumentException with a custom message and error code and parameter name
 Dim ex As ArgumentException
 Set ex = Cor.NewArgumentException("Your argument is wrong.", "MyParam")
 ex.HResult = 123
 Throw ex
 

This example shows how to throw three different variations of the same ArgumentException object.

See Also

Project VBCorLib Overview Class Constructors Overview Constructors Properties Constructors Methods NewApplicationException NewArgumentNullException ArgumentException