| | | 1 | | namespace Allyaria.Abstractions.Exceptions; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents errors that occur due to invalid or unexpected argument values. This exception extends |
| | | 5 | | /// <see cref="AryException" /> to provide additional context about the argument name and value that caused the issue, |
| | | 6 | | /// supporting Allyaria’s structured exception handling model. |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class AryArgumentException : AryException |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Initializes a new instance of the <see cref="AryArgumentException" /> class with optional message, argument name |
| | | 12 | | /// argument value, error code, and inner exception details. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="message">A localized message describing the nature of the argument error.</param> |
| | | 15 | | /// <param name="argName">The name of the argument that caused the exception. May be <see langword="null" />.</param |
| | | 16 | | /// <param name="argValue">The value of the argument that caused the exception. May be <see langword="null" />.</par |
| | | 17 | | /// <param name="errorCode"> |
| | | 18 | | /// An optional structured error code identifying the type of argument error. Defaults to <c>"ARY.ARGUMENT"</c> when |
| | | 19 | | /// specified. |
| | | 20 | | /// </param> |
| | | 21 | | /// <param name="innerException"> |
| | | 22 | | /// The exception that is the cause of the current exception, or <see langword="null" /> if |
| | | 23 | | /// none. |
| | | 24 | | /// </param> |
| | | 25 | | public AryArgumentException(string? message = null, |
| | | 26 | | string? argName = null, |
| | | 27 | | object? argValue = null, |
| | | 28 | | string? errorCode = null, |
| | | 29 | | Exception? innerException = null) |
| | 360 | 30 | | : base( |
| | 360 | 31 | | message: message, |
| | 360 | 32 | | errorCode: errorCode.OrDefaultIfEmpty(defaultValue: "ARY.ARGUMENT"), |
| | 360 | 33 | | innerException: innerException |
| | 360 | 34 | | ) |
| | | 35 | | { |
| | 360 | 36 | | ArgName = argName; |
| | 360 | 37 | | ArgValue = argValue; |
| | 360 | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <summary>Gets the name of the argument that caused the exception.</summary> |
| | | 41 | | /// <value>A <see cref="string" /> representing the argument name, or <see langword="null" /> if not provided.</valu |
| | 64 | 42 | | public string? ArgName { get; } |
| | | 43 | | |
| | | 44 | | /// <summary>Gets the value of the argument that caused the exception.</summary> |
| | | 45 | | /// <value> |
| | | 46 | | /// An <see cref="object" /> representing the problematic argument value, or <see langword="null" /> if not provided |
| | | 47 | | /// </value> |
| | 46 | 48 | | public object? ArgValue { get; } |
| | | 49 | | } |