apperr

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) int

func Is

func Is(err error, code Code) bool

func IsKnownCode

func IsKnownCode(code Code) bool

func Normalize

func Normalize(err error) error

func NormalizeInto

func NormalizeInto(err *error)

func Report

func Report(ctx context.Context, operation string, err error)

Report is called at a transport boundary, once per failed operation. Raw error text and arbitrary attributes can contain secret values, so logs carry only classification, source stack, and safe structured diagnostic fields.

func WithStage added in v0.10.2

func WithStage(stage string, err error) error

WithStage attaches a fixed operation stage for safe diagnostic logging. Stage names must not contain user input or secrets.

Types

type Code

type Code string
const (
	CodeInternal           Code = "internal"
	CodeInvalidArgument    Code = "invalid_argument"
	CodeNotAuthenticated   Code = "not_authenticated"
	CodeAccessDenied       Code = "access_denied"
	CodeAuthExpired        Code = "authentication_expired"
	CodeNotInitialized     Code = "not_initialized"
	CodeConfigNotFound     Code = "config_not_found"
	CodeConfigProtected    Code = "config_protected" // an edit would change the trust root or where secrets are stored
	CodeEnvironmentMissing Code = "environment_not_found"
	CodeEnvironmentExists  Code = "environment_already_exists"
	CodeSecretMissing      Code = "secret_not_found"
	CodeSecretExists       Code = "secret_already_exists"
	CodeImportConflict     Code = "import_conflict"
	CodeArtifactNotFound   Code = "artifact_not_found"
	CodeConflict           Code = "conflict"
	CodeUnavailable        Code = "unavailable"

	// Workspace security protocol.
	CodeNotMember           Code = "not_member"           // device is not (yet) in the verified Control
	CodeUntrusted           Code = "untrusted_state"      // signature, author or encoding failed verification
	CodeRollback            Code = "rollback_detected"    // storage returned something older than accepted
	CodeIncompatibleStorage Code = "incompatible_storage" // storage lacks a workspace control
	CodeSecretConflict      Code = "secret_conflict"      // concurrent edits changed a secret differently; a person must choose
	CodeControlForked       Code = "control_forked"       // two admins changed the members at once; an admin's next operation resolves it
	CodeReencryptIncomplete Code = "reencrypt_incomplete" // membership changed but secrets are not re-encrypted yet
	CodeTrustRootChanged    Code = "trust_root_changed"   // enbu.toml names a genesis other than the one this device pinned

	// Local device.
	CodeIdentityUnavailable Code = "identity_unavailable" // no hardware or keyring backend can hold a key here
	CodeOutputUnreadable    Code = "output_unreadable"    // the output file is not dotenv; pulling again with replace overwrites it
	CodeKeyringLocked       Code = "keyring_locked"       // the OS keyring exists but is locked; the person must unlock it
	CodeUpdateUnverified    Code = "update_unverified"    // a downloaded update failed its signature or checksum and was not installed
)

func CodeOf

func CodeOf(err error) Code

type Error

type Error struct {
	// contains filtered or unexported fields
}

func New

func New(code Code, message string, params Params) *Error

func Wrap

func Wrap(code Code, message string, cause error, params Params) *Error

func (*Error) Code

func (e *Error) Code() Code

func (*Error) Error

func (e *Error) Error() string

func (*Error) Params

func (e *Error) Params() Params

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ExitError

type ExitError struct{ Code int }

ExitError carries the exit status of a command enbu ran on the user's behalf (enbu run). It is not an application error: the command already reported whatever went wrong, enbu only passes its status on.

func (*ExitError) Error

func (e *ExitError) Error() string

type Params

type Params map[string]string

type Payload

type Payload struct {
	Code    Code   `json:"code"`
	Message string `json:"message"`
	Params  Params `json:"params"`
}

func PayloadOf

func PayloadOf(err error) Payload

Jump to

Keyboard shortcuts

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