Documentation
¶
Index ¶
- Constants
- func FromSDK(err error) error
- type Error
- func AsError(err error) *Error
- func ErrAPI(status int, msg string) *Error
- func ErrAmbiguous(resource string, matches []string) *Error
- func ErrAuth(msg string) *Error
- func ErrConflict(status int, msg, hint string, cause error) *Error
- func ErrForbidden(msg string) *Error
- func ErrNetwork(cause error) *Error
- func ErrNotFound(resource, identifier string) *Error
- func ErrRateLimit(retryAfter int) *Error
- func ErrUsage(msg string) *Error
- func ErrUsageHint(msg, hint string) *Error
- func ErrValidation(status int, msg, hint string, cause error) *Error
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
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 ErrAmbiguous ¶
func ErrConflict ¶ added in v0.2.0
func ErrForbidden ¶
func ErrNetwork ¶
func ErrNotFound ¶
func ErrRateLimit ¶
func ErrUsageHint ¶
func ErrValidation ¶ added in v0.2.0
Click to show internal directories.
Click to hide internal directories.