Class ArgumentReservedKeywordException
- Namespace
- Cuemon
- Assembly
- Cuemon.Kernel.dll
The exception that is thrown when the value of an argument is a reserved keyword.
public class ArgumentReservedKeywordException : ArgumentOutOfRangeException, ISerializable
- Inheritance
-
ArgumentReservedKeywordException
- Implements
- Inherited Members
Examples
The following example shows how to throw an ArgumentReservedKeywordException when a parameter value matches a reserved SQL keyword. It demonstrates the expected validation failure and how to catch the exception with access to the parameter name.
using System;
using Cuemon;
namespace MyApp.Validation
{
public class ReservedKeywordValidator
{
private static readonly string[] SqlReservedKeywords = new[]
{
"select", "insert", "update", "delete", "from", "where"
};
public static void ValidateColumnName(string paramName, string value)
{
if (Array.Exists(SqlReservedKeywords,
kw => string.Equals(kw, value, StringComparison.OrdinalIgnoreCase)))
{
throw new ArgumentReservedKeywordException(paramName, value,
"Value must not be a reserved SQL keyword.");
// Usage:
// try { ValidateColumnName("sortBy", "select"); }
// catch (ArgumentReservedKeywordException ex) when (ex.ParamName == "sortBy")
// {
// Console.WriteLine($"Validation failed: {ex.Message}");
// }
}}}
}
Constructors
ArgumentReservedKeywordException()
Initializes a new instance of the ArgumentReservedKeywordException class.
public ArgumentReservedKeywordException()
ArgumentReservedKeywordException(string)
Initializes a new instance of the ArgumentReservedKeywordException class.
public ArgumentReservedKeywordException(string paramName)
Parameters
paramNamestringThe name of the parameter that caused the exception.
ArgumentReservedKeywordException(string, Exception)
Initializes a new instance of the ArgumentReservedKeywordException class.
public ArgumentReservedKeywordException(string message, Exception innerException)
Parameters
messagestringThe message that describes the error.
innerExceptionExceptionThe exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.
ArgumentReservedKeywordException(string, string)
Initializes a new instance of the ArgumentReservedKeywordException class.
public ArgumentReservedKeywordException(string paramName, string message)
Parameters
paramNamestringThe name of the parameter that caused the exception.
messagestringThe message that describes the error.
ArgumentReservedKeywordException(string, string, string)
Initializes a new instance of the ArgumentReservedKeywordException class.
public ArgumentReservedKeywordException(string paramName, string actualValue, string message)