Documentation
¶
Overview ¶
Package errors provides custom error types for the CLI.
Index ¶
- func As(err error, target any) bool
- func ExitCode(err error) int
- type Category
- type Error
- func NewAPI(message string, opts ...Option) *Error
- func NewAuth(message string, opts ...Option) *Error
- func NewInternal(message string, opts ...Option) *Error
- func NewNetwork(message string, opts ...Option) *Error
- func NewRateLimit(message string, opts ...Option) *Error
- func NewTimeout(message string, opts ...Option) *Error
- func NewValidation(message string, opts ...Option) *Error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
type Category string
Category represents the error category.
const ( // CategoryValidation represents validation errors. CategoryValidation Category = "validation" // CategoryAuth represents authentication errors. CategoryAuth Category = "auth" // CategoryAPI represents API errors. CategoryAPI Category = "api" // CategoryNetwork represents network errors. CategoryNetwork Category = "network" // CategoryInternal represents internal errors. CategoryInternal Category = "internal" // CategoryTimeout represents timeout errors. CategoryTimeout Category = "timeout" // CategoryRateLimit represents rate limit errors. CategoryRateLimit Category = "rate_limit" )
type Error ¶
type Error struct {
Category Category `json:"category"`
Message string `json:"message"`
Hint string `json:"hint,omitempty"`
Actions []string `json:"actions,omitempty"`
Retryable bool `json:"retryable"`
RequestID string `json:"request_id,omitempty"`
Cause error `json:"-"`
}
Error is a custom error type with additional context.
func NewInternal ¶
NewInternal creates a new internal error.
func NewNetwork ¶
NewNetwork creates a new network error.
func NewRateLimit ¶
NewRateLimit creates a new rate limit error.
func NewTimeout ¶
NewTimeout creates a new timeout error.
func NewValidation ¶
NewValidation creates a new validation error.
type Option ¶
type Option func(*Error)
Option is a functional option for configuring errors.
func WithActions ¶
WithActions adds suggested actions to the error.
func WithRequestID ¶
WithRequestID adds a request ID to the error.
func WithRetryable ¶
WithRetryable sets whether the error is retryable.
Click to show internal directories.
Click to hide internal directories.