Files
rudder-csharp-sdk/RudderApiException.cs
T
2026-08-12 14:04:55 +03:00

40 lines
1.4 KiB
C#

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