namespace HBank.Sdk;
///
/// The API answered with an error. is the machine-readable error ("invalid_amount",
/// "transaction_not_found", …), the HTTP status (null when HBank couldn't be reached).
///
public class HBankException : Exception
{
public HBankException(string code, int? status, string? detail = null, Exception? inner = null)
: base(detail is null ? code : $"{code}: {detail}", inner)
{
Code = code;
Status = status;
Detail = detail;
}
public string Code { get; }
public int? Status { get; }
/// The readable message some errors carry.
public string? Detail { get; }
}
/// 401 missing_api_key or 403 invalid_api_key.
public sealed class HBankAuthenticationException : HBankException
{
public HBankAuthenticationException(string code, int status, string? detail) : base(code, status, detail) { }
}
///
/// HBank couldn't be reached or didn't answer in time (connection_failed / timeout). The request may or
/// may not have reached HBank: before retrying a refund, check Refunded with GetPaymentAsync.
///
public sealed class HBankConnectionException : HBankException
{
public HBankConnectionException(string code, string detail, Exception inner) : base(code, null, detail, inner) { }
}