Table of Contents

Class ArgumentFormatException

This exception type is useful for an ArgumentException that is also a FormatException. The usual FormatException is probably best reserved for situations not involving method parameters, e.g. parsing a file.

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.

For this reason, 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
System.Object
ArgumentFormatException
Namespace: Galaxon.Core.Exceptions
Assembly: Galaxon.Core.dll
Syntax
public class ArgumentFormatException : ArgumentException

Constructors

ArgumentFormatException()

Initializes a new instance of the ArgumentFormatException class.

Declaration
public ArgumentFormatException()
| Improve this Doc View Source

ArgumentFormatException(Nullable<String>, Nullable<Exception>)

Initializes a new instance of the ArgumentFormatException class with an error message, and (optionally) a reference to the inner exception that is the cause of this exception.

Declaration
public ArgumentFormatException(string? message, Exception? innerException = null)
Parameters
Type Name Description
System.Nullable<System.String> message

The message.

System.Nullable<Exception> innerException

The inner exception.

| Improve this Doc View Source

ArgumentFormatException(Nullable<String>, Nullable<String>, Nullable<Exception>)

Initializes a new instance of the ArgumentFormatException 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 ArgumentFormatException(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.

| Improve this Doc View Source
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX | Galaxy logo by Freepik