Documentation
¶
Overview ¶
Package errors provides typed errors with meaningful exit codes. AI Agents use exit codes to programmatically handle errors without parsing error messages.
Index ¶
- Constants
- type CLIError
- func New(exitCode int, code string, message string) *CLIError
- func NewAuthError(message string) *CLIError
- func NewGeneralError(message string, err error) *CLIError
- func NewNetworkError(message string, err error) *CLIError
- func NewNotFoundError(message string) *CLIError
- func NewPermissionError(message string) *CLIError
- func NewRateLimitError(message string) *CLIError
- func NewUsageError(message string) *CLIError
- func Wrap(exitCode int, code string, message string, err error) *CLIError
Constants ¶
View Source
const ( ExitSuccess = 0 // Operation completed successfully ExitGeneral = 1 // Unspecified error ExitUsage = 2 // Invalid arguments or usage error ExitAuth = 3 // Authentication failure (missing/invalid API key) ExitNotFound = 4 // Requested resource not found ExitRateLimit = 5 // API rate limit exceeded ExitNetwork = 6 // Network connectivity error ExitPermission = 7 // Insufficient permissions )
Exit codes — each maps to a specific error category.
View Source
const ( CodeGeneral = "GENERAL_ERROR" CodeUsage = "USAGE_ERROR" CodeAuth = "AUTH_ERROR" CodeNotFound = "NOT_FOUND" CodeRateLimit = "RATE_LIMITED" CodeNetwork = "NETWORK_ERROR" CodePermission = "PERMISSION_DENIED" )
Error code strings used in JSON error responses.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIError ¶
CLIError is a typed error that carries an exit code and error code string.
func NewAuthError ¶
func NewGeneralError ¶
func NewNetworkError ¶
func NewNotFoundError ¶
func NewPermissionError ¶
func NewRateLimitError ¶
func NewUsageError ¶
Click to show internal directories.
Click to hide internal directories.