| | | 1 | | using System.Management.Automation; |
| | | 2 | | using Kestrun.Logging.Data; |
| | | 3 | | |
| | | 4 | | namespace Kestrun.Logging.Exceptions; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Represents an exception that wraps another exception and optionally an ErrorRecord. |
| | | 8 | | /// </summary> |
| | | 9 | | public class WrapperException : Exception |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Gets the wrapped <see cref="ErrorRecordWrapper"/> associated with this exception, if any. |
| | | 13 | | /// </summary> |
| | 4 | 14 | | public ErrorRecordWrapper? ErrorRecordWrapper { get; } |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of the <see cref="WrapperException"/> class with a specified error message. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <param name="message">The error message that explains the reason for the exception.</param> |
| | 0 | 20 | | public WrapperException(string message) : base(message) |
| | | 21 | | { |
| | 0 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Initializes a new instance of the <see cref="WrapperException"/> class with a specified error message and a refe |
| | | 26 | | /// </summary> |
| | | 27 | | /// <param name="message">The error message that explains the reason for the exception.</param> |
| | | 28 | | /// <param name="innerException">The exception that is the cause of the current exception.</param> |
| | 0 | 29 | | public WrapperException(string message, Exception innerException) : base(message, innerException) |
| | | 30 | | { |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Initializes a new instance of the <see cref="WrapperException"/> class with a specified inner exception and an < |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="innerException">The exception that is the cause of the current exception.</param> |
| | | 37 | | /// <param name="errorRecord">The <see cref="ErrorRecord"/> associated with this exception.</param> |
| | 4 | 38 | | public WrapperException(Exception innerException, ErrorRecord errorRecord) : base(string.Empty, innerException) => E |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Initializes a new instance of the <see cref="WrapperException"/> class. |
| | | 42 | | /// </summary> |
| | 0 | 43 | | public WrapperException() |
| | | 44 | | { |
| | 0 | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Returns a string representation of the inner exception, or an empty string if none exists. |
| | | 49 | | /// </summary> |
| | 0 | 50 | | public override string ToString() => InnerException?.ToString() ?? string.Empty; |
| | | 51 | | } |