Class ArgumentInvalidException
This exception type is useful for an ArgumentException when the argument is invalid for a reason other than being null, out of range, or having an invalid format.
I'm using the same parameter order here as used by ArgumentNullException and ArgumentOutOfRangeException, i.e. (paramName, message), for consistency. The base class, ArgumentException, has the parameters in a different order, i.e. (message, paramName), which can be confusing.
I've resolved not to use ArgumentException anymore but to treat it as an abstract base class. This will avoid the issue with the arguments being out of order, and the lack of specificity.
Normally for any ArgumentException we want to identify the argument causing the exception (which should be done using nameof()), unless there are several, in which case the offending arguments can be identified in the message.
Inheritance
Namespace: Galaxon.Core.Exceptions
Assembly: Galaxon.Core.dll
Syntax
public class ArgumentInvalidException : ArgumentException
Constructors
ArgumentInvalidException()
Initializes a new instance of the ArgumentInvalidException class.
Declaration
public ArgumentInvalidException()
ArgumentInvalidException(Nullable<String>, Nullable<Exception>)
Initializes a new instance of the ArgumentInvalidException class with an error message, and (optionally) a reference to the inner exception that is the cause of this exception.
Declaration
public ArgumentInvalidException(string? message, Exception? innerException = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Nullable<System.String> | message | The message. |
| System.Nullable<Exception> | innerException | The inner exception. |
ArgumentInvalidException(Nullable<String>, Nullable<String>, Nullable<Exception>)
Initializes a new instance of the ArgumentInvalidException class with the parameter name, an error message, and (optionally) a reference to the inner exception that is the cause of this exception.
Declaration
public ArgumentInvalidException(string? paramName, string? message, Exception? innerException = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Nullable<System.String> | paramName | The parameter name. |
| System.Nullable<System.String> | message | The message. |
| System.Nullable<Exception> | innerException | The inner exception. |