| | | 1 | | namespace Allyaria.Abstractions.Exceptions; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents the base exception type for Allyaria applications. All custom exceptions within the Allyaria ecosystem |
| | | 5 | | /// should derive from this type. |
| | | 6 | | /// </summary> |
| | | 7 | | public class AryException : Exception |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Initializes a new instance of the <see cref="AryException" /> class with an optional message, an optional error |
| | | 11 | | /// and an optional inner exception. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="message"> |
| | | 14 | | /// The error message that explains the reason for the exception. This value is typically localized before being pas |
| | | 15 | | /// into the constructor. |
| | | 16 | | /// </param> |
| | | 17 | | /// <param name="errorCode"> |
| | | 18 | | /// An optional, structured error code that categorizes the error. When <see langword="null" /> or empty, this value |
| | | 19 | | /// defaults to <c>"ARY.UNKNOWN"</c>. |
| | | 20 | | /// </param> |
| | | 21 | | /// <param name="innerException"> |
| | | 22 | | /// The exception that is the cause of the current exception, or <see langword="null" /> if no inner exception is |
| | | 23 | | /// specified. |
| | | 24 | | /// </param> |
| | | 25 | | public AryException(string? message = null, string? errorCode = null, Exception? innerException = null) |
| | 406 | 26 | | : base(message: message, innerException: innerException) |
| | 406 | 27 | | => ErrorCode = errorCode.OrDefaultIfEmpty(defaultValue: "ARY.UNKNOWN"); |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the structured error code associated with this exception instance.</summary> |
| | | 30 | | /// <remarks> |
| | | 31 | | /// If no explicit error code is provided when constructing the exception, this property defaults to <c>"ARY.UNKNOWN |
| | | 32 | | /// </remarks> |
| | 78 | 33 | | public string ErrorCode { get; } |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the UTC timestamp indicating when this exception instance was created.</summary> |
| | 418 | 36 | | public DateTimeOffset Timestamp { get; } = DateTimeOffset.UtcNow; |
| | | 37 | | } |