Documentation
¶
Overview ¶
Package sdkerrors defines the SDK error types shared across all packages.
These types are re-exported as type aliases by the public marketdata package.
Index ¶
- Variables
- type APIError
- type AuthenticationError
- type BadRequestError
- type Error
- type ForbiddenError
- type InsecureTokenError
- type InternalError
- type NetworkError
- type NotFoundError
- type ParseError
- type PayloadTooLargeError
- type PaymentRequiredError
- type RateLimitError
- type ResponseTooLargeError
- type ServerError
- type SupportContext
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAuthentication indicates invalid or missing API token (401) ErrAuthentication = errors.New("marketdata: authentication failed") // ErrPaymentRequired indicates the request requires a higher plan (402) ErrPaymentRequired = errors.New("marketdata: payment required") // ErrForbidden indicates access is denied due to IP policy violation (403) ErrForbidden = errors.New("marketdata: forbidden") // ErrBadRequest indicates invalid parameters (400) ErrBadRequest = errors.New("marketdata: bad request") // ErrNotFound indicates the requested resource doesn't exist (404) ErrNotFound = errors.New("marketdata: not found") // ErrPayloadTooLarge indicates the request spans too much data (413) ErrPayloadTooLarge = errors.New("marketdata: payload too large") // ErrRateLimited indicates rate limit has been exceeded (429) ErrRateLimited = errors.New("marketdata: rate limit exceeded") // ErrResponseTooLarge indicates the API response body exceeded the SDK's // safety cap and was refused to protect the caller from memory exhaustion. ErrResponseTooLarge = errors.New("marketdata: response too large") // ErrInsecureToken indicates the SDK refused to transmit the API token // over a connection that is not HTTPS (and not a loopback host). ErrInsecureToken = errors.New("marketdata: refusing to send token over insecure transport") // ErrInternal indicates an internal server error (500) — not retryable ErrInternal = errors.New("marketdata: internal server error") // ErrServer indicates a temporary server error (501-599) — retryable ErrServer = errors.New("marketdata: server error") // ErrInvalidRequest indicates a client-side validation error ErrInvalidRequest = errors.New("marketdata: invalid request") )
Common sentinel errors for quick checks with errors.Is
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
SupportContext
}
APIError represents an unexpected API response where the HTTP status was successful (2xx) but the response body indicated an error (e.g. a status field other than "ok"). It embeds SupportContext (so Message, RequestID, RequestURL, StatusCode, and Timestamp are all populated), implements the Error interface, and is not retryable: the request already got a definitive answer from the API, so resending it would return the same anomalous body.
type AuthenticationError ¶
type AuthenticationError struct {
SupportContext
Cause error
}
AuthenticationError represents a 401 response (invalid or missing token).
func (*AuthenticationError) Error ¶
func (e *AuthenticationError) Error() string
func (*AuthenticationError) Is ¶
func (e *AuthenticationError) Is(target error) bool
func (*AuthenticationError) Retryable ¶
func (e *AuthenticationError) Retryable() bool
func (*AuthenticationError) Unwrap ¶
func (e *AuthenticationError) Unwrap() error
type BadRequestError ¶
type BadRequestError struct {
SupportContext
Cause error
}
BadRequestError represents a 400 response (invalid parameters).
func (*BadRequestError) Error ¶
func (e *BadRequestError) Error() string
func (*BadRequestError) Is ¶
func (e *BadRequestError) Is(target error) bool
func (*BadRequestError) Retryable ¶
func (e *BadRequestError) Retryable() bool
func (*BadRequestError) Unwrap ¶
func (e *BadRequestError) Unwrap() error
type Error ¶
type Error interface {
error
Unwrap() error
// Retryable returns true if the operation can be retried
Retryable() bool
// SupportInfo returns a formatted string for support tickets
SupportInfo() string
}
Error is the interface implemented by all SDK errors.
type ForbiddenError ¶
type ForbiddenError struct {
SupportContext
// AuthorizedIP is the IP address that is currently authorized
AuthorizedIP string
// BlockedIP is the IP address that was blocked
BlockedIP string
// TroubleshootingGuide is a URL to the relevant troubleshooting documentation
TroubleshootingGuide string
Cause error
}
ForbiddenError represents a 403 response (IP policy violation). Occurs when the user's IP address changes and the account is temporarily blocked.
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
func (*ForbiddenError) Is ¶
func (e *ForbiddenError) Is(target error) bool
func (*ForbiddenError) Retryable ¶
func (e *ForbiddenError) Retryable() bool
func (*ForbiddenError) Unwrap ¶
func (e *ForbiddenError) Unwrap() error
type InsecureTokenError ¶
type InsecureTokenError struct {
// Scheme is the URL scheme that was refused (for example "http").
Scheme string
// Host is the target host that was refused.
Host string
}
InsecureTokenError is returned when the SDK is asked to send the API token over a connection that is neither HTTPS nor a loopback host, which would expose the token in cleartext.
func (*InsecureTokenError) Error ¶
func (e *InsecureTokenError) Error() string
func (*InsecureTokenError) Is ¶
func (e *InsecureTokenError) Is(target error) bool
func (*InsecureTokenError) Retryable ¶
func (e *InsecureTokenError) Retryable() bool
func (*InsecureTokenError) Unwrap ¶
func (e *InsecureTokenError) Unwrap() error
type InternalError ¶
type InternalError struct {
SupportContext
Cause error
}
InternalError represents a 500 response (internal server error). This is a permanent failure — include the Ray ID when opening a support ticket.
func (*InternalError) Error ¶
func (e *InternalError) Error() string
func (*InternalError) Is ¶
func (e *InternalError) Is(target error) bool
func (*InternalError) Retryable ¶
func (e *InternalError) Retryable() bool
func (*InternalError) Unwrap ¶
func (e *InternalError) Unwrap() error
type NetworkError ¶
type NetworkError struct {
SupportContext
// Timeout indicates if this was a timeout error
Timeout bool
// Temporary indicates if the error might be transient
Temporary bool
Cause error
}
NetworkError represents a connection failure or timeout.
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Retryable ¶
func (e *NetworkError) Retryable() bool
Retryable returns true for network errors (they are transient).
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type NotFoundError ¶
type NotFoundError struct {
SupportContext
Cause error
}
NotFoundError represents a 404 response.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) Is ¶
func (e *NotFoundError) Is(target error) bool
func (*NotFoundError) Retryable ¶
func (e *NotFoundError) Retryable() bool
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
type ParseError ¶
type ParseError struct {
SupportContext
Cause error
}
ParseError represents a failed response parse.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Retryable ¶
func (e *ParseError) Retryable() bool
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type PayloadTooLargeError ¶
type PayloadTooLargeError struct {
SupportContext
Cause error
}
PayloadTooLargeError represents a 413 response (request spans too much data). Typically occurs when an intraday candle request spans more than 1 year.
func (*PayloadTooLargeError) Error ¶
func (e *PayloadTooLargeError) Error() string
func (*PayloadTooLargeError) Is ¶
func (e *PayloadTooLargeError) Is(target error) bool
func (*PayloadTooLargeError) Retryable ¶
func (e *PayloadTooLargeError) Retryable() bool
func (*PayloadTooLargeError) Unwrap ¶
func (e *PayloadTooLargeError) Unwrap() error
type PaymentRequiredError ¶
type PaymentRequiredError struct {
SupportContext
Cause error
}
PaymentRequiredError represents a 402 response (plan limitation). The request is valid but the user's plan does not include the requested feature or data.
func (*PaymentRequiredError) Error ¶
func (e *PaymentRequiredError) Error() string
func (*PaymentRequiredError) Is ¶
func (e *PaymentRequiredError) Is(target error) bool
func (*PaymentRequiredError) Retryable ¶
func (e *PaymentRequiredError) Retryable() bool
func (*PaymentRequiredError) Unwrap ¶
func (e *PaymentRequiredError) Unwrap() error
type RateLimitError ¶
type RateLimitError struct {
SupportContext
// Limit is the maximum credits allowed in the current window
Limit int
// Remaining is credits remaining (usually 0)
Remaining int
// ResetAt is when the rate limit window resets
ResetAt time.Time
// TroubleshootingGuide is a URL to the relevant troubleshooting documentation
TroubleshootingGuide string
// PreFlight is true when the SDK itself rejected the request before
// sending it, having predicted it would exceed the tracked limit — the
// client-side reservation working as designed, not a server-reported
// failure. Callers that log or alert on this error type may want to
// treat PreFlight rejections as expected throttling rather than a
// genuine failure.
PreFlight bool
Cause error
}
RateLimitError represents a 429 response (rate limit exceeded).
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
func (*RateLimitError) Is ¶
func (e *RateLimitError) Is(target error) bool
func (*RateLimitError) Retryable ¶
func (e *RateLimitError) Retryable() bool
func (*RateLimitError) Unwrap ¶
func (e *RateLimitError) Unwrap() error
func (*RateLimitError) WaitDuration ¶
func (e *RateLimitError) WaitDuration() time.Duration
WaitDuration returns how long to wait before retrying.
type ResponseTooLargeError ¶
type ResponseTooLargeError struct {
SupportContext
// Limit is the maximum number of response bytes the SDK will read.
Limit int64
Cause error
}
ResponseTooLargeError is returned when an API response body exceeds the SDK's configured size cap. The SDK stops reading and refuses the response so a hostile or malfunctioning server cannot exhaust the caller's memory.
func (*ResponseTooLargeError) Error ¶
func (e *ResponseTooLargeError) Error() string
func (*ResponseTooLargeError) Is ¶
func (e *ResponseTooLargeError) Is(target error) bool
func (*ResponseTooLargeError) Retryable ¶
func (e *ResponseTooLargeError) Retryable() bool
func (*ResponseTooLargeError) Unwrap ¶
func (e *ResponseTooLargeError) Unwrap() error
type ServerError ¶
type ServerError struct {
SupportContext
Cause error
}
ServerError represents a temporary server error (501-599). These are transient failures that should resolve after a brief wait.
func (*ServerError) Error ¶
func (e *ServerError) Error() string
func (*ServerError) Is ¶
func (e *ServerError) Is(target error) bool
func (*ServerError) Retryable ¶
func (e *ServerError) Retryable() bool
Retryable returns true — all 501-599 errors are transient.
func (*ServerError) Unwrap ¶
func (e *ServerError) Unwrap() error
type SupportContext ¶
type SupportContext struct {
// RequestID is the cf-ray response header value
RequestID string
// RequestURL is the full request URL
RequestURL string
// StatusCode is the HTTP status code
StatusCode int
// Timestamp is when the error occurred (US/Eastern)
Timestamp time.Time
// Message is the error description
Message string
// ExceptionType is the error type name
ExceptionType string
}
SupportContext contains fields included in every API error for support troubleshooting.
func (SupportContext) SupportInfo ¶
func (s SupportContext) SupportInfo() string
SupportInfo returns a formatted support string for support tickets.
type ValidationError ¶
type ValidationError struct {
// Field is the invalid field name
Field string
// Message describes what's wrong
Message string
}
ValidationError represents invalid input parameters. This is used for client-side validation before making a request.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Is ¶
func (e *ValidationError) Is(target error) bool
func (*ValidationError) Retryable ¶
func (e *ValidationError) Retryable() bool
func (*ValidationError) SupportInfo ¶
func (e *ValidationError) SupportInfo() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error