namespace ERPCore.System.Errors;

/// <summary>
/// Base for domain / business-rule violations. Carries a stable <see cref="Code"/>
/// (see the error catalog in docs/11-BACKEND-PHASE1.md) and an HTTP
/// <see cref="StatusCode"/>; mapped to RFC 7807 ProblemDetails by
/// <see cref="DomainExceptionHandler"/>.
/// </summary>
public class DomainException : Exception
{
    public string Code { get; }
    public int StatusCode { get; }

    public DomainException(string code, string message, int statusCode = 400)
        : base(message)
    {
        Code = code;
        StatusCode = statusCode;
    }
}

/// <summary>404 — a referenced resource does not exist.</summary>
public sealed class NotFoundException : DomainException
{
    public NotFoundException(string message) : base(ErrorCodes.NotFound, message, 404) { }
}

/// <summary>409 — the request conflicts with current server state.</summary>
public sealed class ConflictException : DomainException
{
    public ConflictException(string message) : base(ErrorCodes.Conflict, message, 409) { }
}
