errors

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitOK       = 0
	ExitUsage    = 1
	ExitNotFound = 2
	ExitAuth     = 3
	ExitForbid   = 4
	ExitRate     = 5
	ExitNetwork  = 6
	ExitAPI      = 7
	ExitAmbig    = 8
)

Exit codes follow a shared rubric across CLI tools.

View Source
const (
	CodeUsage    = "usage"
	CodeNotFound = "not_found"
	CodeAuth     = "auth"
	CodeForbid   = "forbidden"
	CodeRate     = "rate_limit"
	CodeNetwork  = "network"
	CodeAPI      = "api"
	CodeAmbig    = "ambiguous"
)

Error code strings.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code       string `json:"code"`
	Message    string `json:"error"`
	Hint       string `json:"hint,omitempty"`
	HTTPStatus int    `json:"-"`
	Retryable  bool   `json:"-"`
	Cause      error  `json:"-"`
}

Error is a structured CLI error with code, message, hint, and optional cause.

func AsError

func AsError(err error) *Error

AsError converts any error to a structured *Error.

func ErrAPI

func ErrAPI(status int, msg string) *Error

func ErrAmbiguous

func ErrAmbiguous(msg string) *Error

func ErrAuth

func ErrAuth(msg string) *Error

func ErrDAVNotConfigured

func ErrDAVNotConfigured() *Error

func ErrForbidden

func ErrForbidden(msg string) *Error

func ErrNetwork

func ErrNetwork(cause error) *Error

func ErrNotFound

func ErrNotFound(resource, identifier string) *Error

func ErrNotFoundHint

func ErrNotFoundHint(resource, identifier, hint string) *Error

func ErrRateLimit

func ErrRateLimit(retryAfter int) *Error

func ErrUsage

func ErrUsage(msg string) *Error

func FromHTTPStatus

func FromHTTPStatus(status int, body string) *Error

FromHTTPStatus creates the appropriate Error from an HTTP status code.

func (*Error) Error

func (e *Error) Error() string

func (*Error) ExitCode

func (e *Error) ExitCode() int

ExitCode returns the process exit code for this error.

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