using System.Net;

namespace adas_core.Domain.Exceptions;

/// <summary>
/// Represents an exception that aggregates one or more errors related to business logic or domain rule violations.
/// </summary>
/// <!-- aidoc:v1 sig=10da46f -->
public class BusinessException : AggregateException
{
    /// <summary>
    /// Initializes a new instance of the <see cref="BusinessException"/> class with the supplied <see cref="HttpStatusCode"/> and message, forwarding their combined textual representation to the base exception constructor. <see cref="BusinessException"/> represents errors raised by business logic that are associated with an HTTP status.
    /// </summary>
    /// <param name="status">The <see cref="HttpStatusCode"/> that identifies the nature of the business error.</param>
    /// <param name="message">The descriptive message that provides additional context for the error.</param>
    /// <!-- aidoc:v1 sig=0825145 body=4448e1d -->
    public BusinessException(HttpStatusCode status, string message) : base($"{status}: {message}")
    {
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="BusinessException"/> class, which represents errors in business logic, by passing the specified error message and inner <see cref="Exception"/> to the base class constructor.
    /// </summary>
    /// <param name="message">The error message that describes the reason for the exception.</param>
    /// <param name="exception">The inner <see cref="Exception"/> that is the cause of the current exception, or <see langword="null"/> if no inner exception is specified.</param>
    /// <!-- aidoc:v1 sig=cd57c0c body=4448e1d -->
    public BusinessException(string message, Exception exception) : base(message, exception)
    {
    }
}