errors

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errors provides SDK error types without CLI-specific hints. The CLI layer wraps these with user-facing hints.

Index

Constants

View Source
const (
	CodeUsage     = "usage"
	CodeNotFound  = "not_found"
	CodeAuth      = "auth_required"
	CodeForbidden = "forbidden"
	CodeRateLimit = "rate_limit"
	CodeNetwork   = "network"
	CodeAPI       = "api_error"
	CodeAmbiguous = "ambiguous"
)

Error codes.

View Source
const (
	ExitOK        = 0 // Success
	ExitUsage     = 1 // Invalid arguments or flags
	ExitNotFound  = 2 // Resource not found
	ExitAuth      = 3 // Not authenticated
	ExitForbidden = 4 // Access denied (scope issue)
	ExitRateLimit = 5 // Rate limited (429)
	ExitNetwork   = 6 // Connection/DNS/timeout error
	ExitAPI       = 7 // Server returned error
	ExitAmbiguous = 8 // Multiple matches for name
)

Exit codes.

Variables

This section is empty.

Functions

func ExitCodeFor

func ExitCodeFor(code string) int

ExitCodeFor returns the exit code for a given error code.

Types

type Error

type Error struct {
	Code       string // Error code (e.g., "not_found", "auth_required")
	Message    string // Error message
	HTTPStatus int    // HTTP status code if applicable
	Retryable  bool   // Whether the operation can be retried
	Cause      error  // Underlying error
}

Error is a structured error for SDK operations. Unlike output.Error, it does not contain CLI-specific hints.

func ErrAPI

func ErrAPI(status int, msg string) *Error

ErrAPI creates an API error.

func ErrAmbiguous

func ErrAmbiguous(resource string, matches []string) *Error

ErrAmbiguous creates an ambiguous match error.

func ErrAuth

func ErrAuth(msg string) *Error

ErrAuth creates an authentication error.

func ErrForbidden

func ErrForbidden(msg string) *Error

ErrForbidden creates a forbidden error.

func ErrNetwork

func ErrNetwork(cause error) *Error

ErrNetwork creates a network error.

func ErrNotFound

func ErrNotFound(resource, identifier string) *Error

ErrNotFound creates a not found error.

func ErrRateLimit

func ErrRateLimit(retryAfter int) *Error

ErrRateLimit creates a rate limit error.

func ErrUsage

func ErrUsage(msg string) *Error

ErrUsage creates a usage error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL