errfmt

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess    = 0
	ExitFailure    = 1
	ExitUsageError = 2
)

Exit codes

View Source
const (
	ErrCodeAuth       = "AUTH_ERROR"
	ErrCodeNotFound   = "NOT_FOUND"
	ErrCodeValidation = "VALIDATION_ERROR"
	ErrCodeConnection = "CONNECTION_ERROR"
	ErrCodeInternal   = "INTERNAL_ERROR"
)

Error codes for envelope responses

Variables

This section is empty.

Functions

func ErrorCode added in v0.8.0

func ErrorCode(err error) string

ErrorCode maps an error to an error code string.

func Format

func Format(err error) string

Format converts an error to a user-friendly message.

func Hint added in v0.13.0

func Hint(err error) string

Hint returns an optional actionable hint for known error patterns.

func NewEnableCommandsError added in v0.13.0

func NewEnableCommandsError(command string, allowlist []string) error

NewEnableCommandsError creates an allowlist restriction error.

func NewReadonlyError added in v0.13.0

func NewReadonlyError(command string) error

NewReadonlyError creates a readonly restriction error.

Types

type ExitError

type ExitError struct {
	Err  error
	Code int
}

ExitError wraps an error with an exit code.

func UsageError

func UsageError(format string, args ...any) *ExitError

UsageError creates an error with exit code 2.

func WithCode

func WithCode(err error, code int) *ExitError

WithCode wraps an error with an exit code.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type RestrictionError added in v0.13.0

type RestrictionError struct {
	Kind      RestrictionKind
	Command   string
	Allowlist []string
}

RestrictionError reports command safety restriction violations.

func (*RestrictionError) Error added in v0.13.0

func (e *RestrictionError) Error() string

type RestrictionKind added in v0.13.0

type RestrictionKind string

RestrictionKind identifies command safety restriction types.

const (
	// RestrictionEnableCommands indicates command allowlist blocking.
	RestrictionEnableCommands RestrictionKind = "enable_commands"
	// RestrictionReadonly indicates readonly mode blocking.
	RestrictionReadonly RestrictionKind = "readonly"
)

Jump to

Keyboard shortcuts

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