Documentation
¶
Overview ¶
Package errors provides custom error types for the OpenCTEM SDK. It follows industry best practices (HashiCorp, AWS SDK) for error handling.
Index ¶
- Variables
- func E(args ...interface{}) error
- func IsAuthenticationError(err error) bool
- func IsAuthorizationError(err error) bool
- func IsNetworkError(err error) bool
- func IsNotFoundError(err error) bool
- func IsRateLimitError(err error) bool
- func IsRetryable(err error) bool
- func IsTimeoutError(err error) bool
- func New(message string) error
- func Wrap(err error, op string) error
- func WrapWithMessage(err error, message string) error
- type APIError
- type Error
- type Kind
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotConnected is returned when the client is not connected. ErrNotConnected = &Error{Kind: KindNetwork, Message: "not connected"} // ErrTimeout is returned when an operation times out. ErrTimeout = &Error{Kind: KindTimeout, Message: "operation timed out"} // ErrRateLimited is returned when rate limited. ErrRateLimited = &Error{Kind: KindRateLimit, Message: "rate limited"} // ErrInvalidConfig is returned for invalid configuration. ErrInvalidConfig = &Error{Kind: KindInvalidInput, Message: "invalid configuration"} // ErrMissingAPIKey is returned when API key is missing. ErrMissingAPIKey = &Error{Kind: KindAuthentication, Message: "API key is required"} // ErrMissingAgentID is returned when agent ID is missing. ErrMissingAgentID = &Error{Kind: KindInvalidInput, Message: "agent ID is required"} )
Functions ¶
func E ¶
func E(args ...interface{}) error
E constructs an Error from the given arguments. Arguments can be: Kind, string (Op or Message), error.
func IsAuthenticationError ¶
IsAuthenticationError checks if the error is an authentication error.
func IsAuthorizationError ¶
IsAuthorizationError checks if the error is an authorization error.
func IsNetworkError ¶
IsNetworkError checks if the error is a network error.
func IsNotFoundError ¶
IsNotFoundError checks if the error is a not found error.
func IsRateLimitError ¶
IsRateLimitError checks if the error is a rate limit error.
func IsTimeoutError ¶
IsTimeoutError checks if the error is a timeout error.
func WrapWithMessage ¶
WrapWithMessage wraps an error with a message.
Types ¶
type APIError ¶
type APIError struct {
// StatusCode is the HTTP status code
StatusCode int `json:"status_code"`
// Code is an API-specific error code
Code string `json:"code"`
// Message is the error message from the API
Message string `json:"message"`
// RequestID is the request ID for debugging
RequestID string `json:"request_id,omitempty"`
// Details contains additional error context
Details map[string]any `json:"details,omitempty"`
}
APIError represents an error returned by the OpenCTEM API.
func IsAPIError ¶
IsAPIError checks if err is an APIError and returns it.
type Error ¶
type Error struct {
// Kind indicates the category of error
Kind Kind
// Op is the operation being performed (e.g., "client.PushFindings")
Op string
// Message is a human-readable description
Message string
// Err is the underlying error
Err error
}
Error is the base error type for all SDK errors.