errs

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errs is the public re-export surface for raid's structured errors. The concrete types and constructors live in src/internal/lib/errs; this package aliases them so callers in src/cmd/ and other public packages depend only on this stable surface.

Every code is part of raid's CLI contract: codes never change name or category across minor versions; new codes ship additively. See /docs/references/errors for the full table and the JSON shape.

Index

Constants

View Source
const (
	CategoryGeneric  = liberrs.CategoryGeneric
	CategoryConfig   = liberrs.CategoryConfig
	CategoryTask     = liberrs.CategoryTask
	CategoryNetwork  = liberrs.CategoryNetwork
	CategoryNotFound = liberrs.CategoryNotFound
)

Category constants — values match the documented CLI exit codes.

View Source
const (
	CodeUnknown                 = liberrs.CodeUnknown
	CodeInternal                = liberrs.CodeInternal
	CodeGitNotInstalled         = liberrs.CodeGitNotInstalled
	CodeLockFailed              = liberrs.CodeLockFailed
	CodeProfileInvalid          = liberrs.CodeProfileInvalid
	CodeProfileFileRead         = liberrs.CodeProfileFileRead
	CodeProfileAlreadyExists    = liberrs.CodeProfileAlreadyExists
	CodeRepoInvalid             = liberrs.CodeRepoInvalid
	CodeConfigInvalid           = liberrs.CodeConfigInvalid
	CodeConfigLoadFailed        = liberrs.CodeConfigLoadFailed
	CodeSchemaValidationFailed  = liberrs.CodeSchemaValidationFailed
	CodeArgInvalid              = liberrs.CodeArgInvalid
	CodeTaskFailed              = liberrs.CodeTaskFailed
	CodeTaskShellFailed         = liberrs.CodeTaskShellFailed
	CodeTaskScriptFailed        = liberrs.CodeTaskScriptFailed
	CodeTaskWaitTimeout         = liberrs.CodeTaskWaitTimeout
	CodeTaskTemplateFailed      = liberrs.CodeTaskTemplateFailed
	CodeTaskGitFailed           = liberrs.CodeTaskGitFailed
	CodeCloneFailed             = liberrs.CodeCloneFailed
	CodeTaskHTTPFailed          = liberrs.CodeTaskHTTPFailed
	CodeProfileNotFound         = liberrs.CodeProfileNotFound
	CodeProfileNotActive        = liberrs.CodeProfileNotActive
	CodeProfileFileMissing      = liberrs.CodeProfileFileMissing
	CodeRepoNotFound            = liberrs.CodeRepoNotFound
	CodeRepoNotCloned           = liberrs.CodeRepoNotCloned
	CodeEnvNotFound             = liberrs.CodeEnvNotFound
	CodeCommandNotFound         = liberrs.CodeCommandNotFound
	CodeVerifyFailed            = liberrs.CodeVerifyFailed
	CodeHeadlessPromptNoDefault = liberrs.CodeHeadlessPromptNoDefault
)

Stable code strings. Documented at /docs/references/errors.

Variables

This section is empty.

Functions

func EmitJSON

func EmitJSON(w io.Writer, err error)

EmitJSON writes a structured `{"error": {…}}` document to w.

func ExitCode

func ExitCode(err error) int

ExitCode returns the raid CLI exit code for an error. Nil → 0.

func IsReservedErrorKey added in v0.17.2

func IsReservedErrorKey(k string) bool

IsReservedErrorKey reports whether k is reserved by the structured error envelope (code/message/category/hint). Peer emitters that flatten Details() into their own JSON shape (e.g. the MCP tool- result builder) should consult this so envelope keys don't get overwritten by accidental Details collisions.

Types

type Category

type Category = liberrs.Category

Category buckets errors by exit-code class.

type Error

type Error = liberrs.Error

Error is the structured-error interface every raid failure satisfies.

func ArgInvalid

func ArgInvalid(msg string) Error

func AsError

func AsError(err error) (Error, bool)

AsError walks the wrapped-error chain and returns the first Error.

func CloneFailed

func CloneFailed(name, url string, cause error) Error

func CommandNotFound

func CommandNotFound(name string) Error

func ConfigInvalid

func ConfigInvalid(cause error) Error

func ConfigLoadFailed

func ConfigLoadFailed(cause error) Error

func EnvNotFound

func EnvNotFound(name string) Error

func GitNotInstalled

func GitNotInstalled() Error

func HeadlessPromptNoDefault

func HeadlessPromptNoDefault(varName string) Error

func Internal

func Internal(msg string) Error

func LockFailed

func LockFailed(cause error) Error

func Newf

func Newf(code string, category Category, format string, args ...any) Error

Newf builds a structured error with an arbitrary formatted message. Prefer the dedicated constructors below — this exists for call sites that need to preserve a specific historic wording for back-compat.

func ProfileAlreadyExists

func ProfileAlreadyExists(name string) Error

func ProfileFileMissing

func ProfileFileMissing(path string) Error

func ProfileFileRead

func ProfileFileRead(path string, cause error) Error

func ProfileInvalid

func ProfileInvalid(path string, cause error) Error

func ProfileNotActive

func ProfileNotActive() Error

func ProfileNotFound

func ProfileNotFound(name string) Error

func RepoInvalid

func RepoInvalid(name string, cause error) Error

func RepoNotCloned

func RepoNotCloned(name, path string) Error

func RepoNotFound

func RepoNotFound(name string) Error

func SchemaValidationFailed

func SchemaValidationFailed(path string, cause error) Error

func TaskFailed

func TaskFailed(taskType string, cause error) Error

func TaskGitFailed

func TaskGitFailed(cause error) Error

func TaskHTTPFailed

func TaskHTTPFailed(url string, cause error) Error

func TaskScriptFailed

func TaskScriptFailed(cause error) Error

func TaskShellFailed

func TaskShellFailed(cause error) Error

func TaskTemplateFailed

func TaskTemplateFailed(cause error) Error

func TaskWaitTimeout

func TaskWaitTimeout(target string, cause error) Error

func Unknown

func Unknown(cause error) Error

func VerifyFailed

func VerifyFailed(name string, cause error) Error

func Wrap

func Wrap(err error) Error

Wrap returns err unchanged if it already implements Error, else wraps it as Unknown. Returns nil for nil.

Jump to

Keyboard shortcuts

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