Error

Error is the error type returned by New, the Client methods, VerifySession, TargetsParam, TargetsHash and ParseISODuration.

On this page

Error is the error type returned by New, the Client methods, VerifySession, TargetsParam, TargetsHash and ParseISODuration. The pluggable helpers OpenSystemBrowser, PromptStdin and DirStorage return ordinary errors. Use errors.As to inspect Code:

var skErr *sponsorkit.Error
if errors.As(err, &skErr) && skErr.Code == sponsorkit.CodeDisabled { ... }
type Error struct {
	Code       ErrorCode
	Message    string
	Err        error
	RetryAfter *time.Duration
}

Fields#

Code#

Code ErrorCode

Code is the machine-readable error code.

Message#

Message string

Message is a human-readable description.

Err#

Err error

Err is the underlying cause, if any (for example context.Canceled).

RetryAfter#

RetryAfter *time.Duration

RetryAfter is how long the API asked the caller to wait (its Retry-After header) on a network_error from SignIn or VerifySession, whatever the HTTP status (429, 503 or any other unexpected response). It is nil when the API sent no usable Retry-After.

Methods#

Error#

func (e *Error) Error() string

Error formats the error as "sponsorkit: <code>: <message>", followed by ": <cause>" when Err is set.

View source

Is#

func (e *Error) Is(target error) bool

Is reports whether target is an *Error with the same Code, so that errors.Is(err, &sponsorkit.Error{Code: sponsorkit.CodeDisabled}) works.

View source

Unwrap#

func (e *Error) Unwrap() error

Unwrap returns the underlying cause.

View source