using System.Net;
using IdokladSdk.Enums;

namespace Idoklad.Client;

/// <summary>
/// Raised when an upstream iDoklad API call does not succeed. Carries the upstream HTTP status
/// code, message and iDoklad error code so the failure can be surfaced to the caller.
/// </summary>
public sealed class IdokladApiException : Exception
{
    public HttpStatusCode StatusCode { get; }
    public DokladErrorCode ErrorCode { get; }

    public IdokladApiException(HttpStatusCode statusCode, DokladErrorCode errorCode, string? message)
        : base(string.IsNullOrWhiteSpace(message) ? "iDoklad API request failed." : message)
    {
        StatusCode = statusCode;
        ErrorCode = errorCode;
    }
}
