Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user