apperr

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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
)

Jump to

Keyboard shortcuts

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