SponsorkitError

The exception type for every error Sponsorkit raises on purpose.

On this page

The exception type for every error Sponsorkit raises on purpose. Code is a stable, machine-readable error code (see SponsorkitErrorCodes). The SDK also throws the standard ArgumentException and ArgumentNullException for invalid arguments, and OperationCanceledException when a CancellationToken you pass is cancelled (except in sign-in, which throws the cancelled code, and checkout, which returns CheckoutStatus.Unknown).

namespace Sponsorkit;

public sealed class SponsorkitError : Exception

Inherits from Exception.

SponsorkitClient.GetFinancialContributionAsync never throws because Sponsorkit or a provider is unreachable: network errors, 5xx and rate limits are reported through ContributionResult.Stale instead. Errors are thrown for configuration mistakes and for user-initiated actions (sign-in, checkout) that cannot complete.

Constructors#

MemberDescription
SponsorkitError(string, string, Exception)Creates an error with the given code and message.
SponsorkitError(string, string, TimeSpan?, Exception)Creates an error that carries a Retry-After delay.

SponsorkitError(string, string, Exception)#

public SponsorkitError(string code, string? message = null, Exception? innerException = null)

Creates an error with the given code and message.

Parameters

  • code string: One of SponsorkitErrorCodes.
  • message string?: A human-readable description. Optional (default null).
  • innerException Exception?: The underlying exception, if any. Optional (default null).

SponsorkitError(string, string, TimeSpan?, Exception)#

public SponsorkitError(string code, string? message, TimeSpan? retryAfter, Exception? innerException)

Creates an error that carries a Retry-After delay.

Parameters

  • code string: One of SponsorkitErrorCodes.
  • message string?: A human-readable description.
  • retryAfter TimeSpan?: How long the API asked the caller to wait, or null.
  • innerException Exception?: The underlying exception, if any.

Properties#

MemberDescription
CodeThe machine-readable error code, for example invalid_config or access_denied.
RetryAfterFor network_error caused by a rate limit: how long the API asked the caller to wait (its Retry-After header).

Code#

public string Code { get; }

The machine-readable error code, for example invalid_config or access_denied.

Type: string

RetryAfter#

public TimeSpan? RetryAfter { get; }

For network_error caused by a rate limit: how long the API asked the caller to wait (its Retry-After header). null when the API sent none.

Type: TimeSpan?