Table of Contents

Class ArgumentTypeException

Namespace
Existential
Assembly
Existential.Net.dll

A custom exception that represents errors when a method argument is of an unexpected type. It extends the System.ArgumentException class, adding more specific context to the error scenario.

[Serializable]
public class ArgumentTypeException : ArgumentException, ISerializable
Inheritance
System.Object
System.Exception
System.SystemException
System.ArgumentException
ArgumentTypeException
Implements
System.Runtime.Serialization.ISerializable
Inherited Members
System.ArgumentException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)
System.ArgumentException.Message
System.ArgumentException.ParamName
System.Exception.GetBaseException()
System.Exception.GetType()
System.Exception.ToString()
System.Exception.Data
System.Exception.HelpLink
System.Exception.HResult
System.Exception.InnerException
System.Exception.Source
System.Exception.StackTrace
System.Exception.TargetSite
System.Exception.SerializeObjectState
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Extension Methods

Remarks

This exception is useful when you have methods that expect arguments of a certain type, and you want to enforce this at runtime. If an argument of an incorrect type is passed, this exception can be thrown to indicate the exact nature of the error.

The class provides several constructors to create an instance of the exception, allowing you to specify an error message, an inner exception, or the name of the parameter that caused the exception.This provides flexibility in reporting the error details.

Constructors

ArgumentTypeException()

Initialises a new instance of the ArgumentTypeException class without any message.

public ArgumentTypeException()

Remarks

This constructor creates an ArgumentTypeException with no error message or inner exception details.

ArgumentTypeException(SerializationInfo, StreamingContext)

Initialises a new instance of the ArgumentTypeException class with serialised data.

protected ArgumentTypeException(SerializationInfo inInfo, StreamingContext inContext)

Parameters

inInfo System.Runtime.Serialization.SerializationInfo

The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown.

inContext System.Runtime.Serialization.StreamingContext

The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination.

Remarks

This constructor is called during deserialisation to reconstitute the exception object transmitted over a stream. For more information, see XML and SOAP Serialization .

ArgumentTypeException(String)

Initialises a new instance of the ArgumentTypeException class with a specified error message.

public ArgumentTypeException(string inMessage)

Parameters

inMessage System.String

The message that describes the error.

ArgumentTypeException(String, Exception)

Initialises a new instance of the ArgumentTypeException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public ArgumentTypeException(string inMessage, Exception inException)

Parameters

inMessage System.String

The error message that explains the reason for the exception.

inException System.Exception

The exception that is the cause of the current exception. If the inException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.

ArgumentTypeException(String, String)

Initialises a new instance of the ArgumentTypeException class with a specified error message and the name of the parameter that causes this exception.

public ArgumentTypeException(string inMessage, string inParameterName)

Parameters

inMessage System.String

The error message that explains the reason for the exception.

inParameterName System.String

The name of the parameter with the unexpected type that caused the current exception.