using System;
namespace RudderSdk.Core;
///
/// Base exception for every API failure. Carries the HTTP status code
/// (0 for network failures, see ), the
/// machine-readable API error code (see ) and the
/// server-issued request id when available.
///
public class RudderApiException : Exception
{
/// HTTP status code, or 0 when the request never reached the server.
public int StatusCode { get; }
/// Machine-readable API error code, or an empty string.
public string Code { get; }
/// Server-issued request id for support tickets, or null.
public string? RequestId { get; }
/// Creates the exception.
public RudderApiException(int statusCode, string? code, string message, string? requestId = null)
: base(message)
{
StatusCode = statusCode;
Code = code ?? string.Empty;
RequestId = requestId;
}
/// Creates the exception wrapping an inner transport error.
public RudderApiException(int statusCode, string? code, string message, string? requestId, Exception? innerException)
: base(message, innerException)
{
StatusCode = statusCode;
Code = code ?? string.Empty;
RequestId = requestId;
}
}