apierr

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUsage      = "usage"
	CodeNotFound   = "not_found"
	CodeAuth       = "auth"
	CodeForbidden  = "forbidden"
	CodeRateLimit  = "rate_limit"
	CodeNetwork    = "network"
	CodeAPI        = "api"
	CodeAmbiguous  = "ambiguous"
	CodeValidation = "validation"
	CodeConflict   = "conflict"
	CodeUnknown    = "unknown"
)

The codes an Error carries. output.ExitCodeFor maps them onto exit codes and they reach a scripting caller as the envelope's "code", so both sides read them from here rather than spelling them out and hoping.

Variables

This section is empty.

Functions

func FromSDK added in v0.2.0

func FromSDK(err error) error

FromSDK maps an SDK error onto the CLI's error shape, which is what decides the exit code, the JSON envelope and the sentence somebody reads. It lives here rather than next to the commands because the TUI hits the same API and wants the same sentence: half the callers could not reach it in internal/cmd.

Types

type Error

type Error struct {
	Code       string
	Message    string
	Hint       string
	HTTPStatus int
	Cause      error

	// Meta carries structured context into the JSON error envelope — e.g. the
	// per-step results of a partially failed setup, which a scripting caller
	// needs to know what did land.
	Meta map[string]any
}

Error is a typed error carrying a machine-readable code, human message, optional hint, and metadata used for exit-code decisions.

func AsError

func AsError(err error) *Error

func ErrAPI

func ErrAPI(status int, msg string) *Error

func ErrAmbiguous

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

func ErrAuth

func ErrAuth(msg string) *Error

func ErrConflict added in v0.2.0

func ErrConflict(status int, msg, hint string, cause error) *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 added in v1.0.0

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

func ErrRateLimit

func ErrRateLimit(retryAfter int) *Error

func ErrUsage

func ErrUsage(msg string) *Error

func ErrUsageHint

func ErrUsageHint(msg, hint string) *Error

func ErrValidation added in v0.2.0

func ErrValidation(status int, msg, hint string, cause error) *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