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 : ExceptionInherits 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#
| Member | Description |
|---|---|
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
codestring: One ofSponsorkitErrorCodes.messagestring?: A human-readable description. Optional (defaultnull).innerExceptionException?: The underlying exception, if any. Optional (defaultnull).
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
codestring: One ofSponsorkitErrorCodes.messagestring?: A human-readable description.retryAfterTimeSpan?: How long the API asked the caller to wait, ornull.innerExceptionException?: The underlying exception, if any.
Properties#
| Member | Description |
|---|---|
Code | The machine-readable error code, for example invalid_config or access_denied. |
RetryAfter | For 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?