apperr

package
v0.8.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(op string, kind Kind, msg string, errs ...error) error

Aggregate wraps one or more errors with a stable kind and operation. nil errors are ignored. Returns nil when errs has no non-nil entries.

func IsKind

func IsKind(err error, k Kind) bool

IsKind reports whether any error in the chain is an *E of the provided Kind.

func New

func New(op string, kind Kind, msg string, args ...any) error

New creates a new E with no wrapped cause.

func Wrap

func Wrap(op string, kind Kind, err error, msg string, args ...any) error

Wrap creates an E that wraps the provided error with operation, kind, and message.

Types

type E

type E struct {
	Op   string // where it happened, e.g. "dockercli.SyncVolume"
	Kind Kind   // category
	Err  error  // wrapped cause
	Msg  string // optional, short context message
}

E is a rich, chainable error.

func (*E) Error

func (e *E) Error() string

func (*E) Unwrap

func (e *E) Unwrap() error

type Kind

type Kind string

Kind is a stable category for application errors.

const (
	// Stable kinds you can switch/branch on across packages.
	InvalidInput Kind = "invalid_input"
	NotFound     Kind = "not_found"
	Conflict     Kind = "conflict"
	Unauthorized Kind = "unauthorized"
	Forbidden    Kind = "forbidden"
	Precondition Kind = "precondition_failed"
	Timeout      Kind = "timeout"
	Unavailable  Kind = "unavailable" // network/docker daemon down
	External     Kind = "external"    // external tool failed (docker/sops)
	Internal     Kind = "internal"    // programmer bug, invariant broken
)

type MultiError

type MultiError struct {
	Errors []error
}

MultiError groups multiple errors and supports errors.Is/errors.As traversal.

func (*MultiError) Error

func (m *MultiError) Error() string

func (*MultiError) Unwrap

func (m *MultiError) Unwrap() []error

Unwrap exposes all inner errors for errors.Is/errors.As in Go 1.20+.

Jump to

Keyboard shortcuts

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