Error
Error is the error type returned by New, the Client methods, VerifySession, TargetsParam, TargetsHash and ParseISODuration.
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 ErrorCodeCode is the machine-readable error code.
Message#
Message stringMessage is a human-readable description.
Err#
Err errorErr is the underlying cause, if any (for example context.Canceled).
RetryAfter#
RetryAfter *time.DurationRetryAfter 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() stringError formats the error as "sponsorkit: <code>: <message>", followed by ": <cause>" when Err is set.
Is#
func (e *Error) Is(target error) boolIs reports whether target is an *Error with the same Code, so that errors.Is(err, &sponsorkit.Error{Code: sponsorkit.CodeDisabled}) works.
Unwrap#
func (e *Error) Unwrap() errorUnwrap returns the underlying cause.