errors

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As finds the first error in err's chain that matches target

func FormatError

func FormatError(err error, includeStack bool) string

FormatError formats an error for display, optionally including stack trace

func Is

func Is(err, target error) bool

Is reports whether any error in err's chain matches target

func Wrap

func Wrap(err error, message string) error

Wrap wraps an error with additional context

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf wraps an error with formatted context

Types

type CLIError

type CLIError struct {
	// TechnicalError is the underlying technical error (for logging)
	TechnicalError error
	// UserMsg is the user-friendly error message
	UserMsg string
	// ExitCode is the exit code to return
	ExitCode ExitCode
	// StackTrace contains the call stack when debug mode is enabled
	StackTrace string
}

CLIError represents a CLI error with user-friendly message and exit code

func NewAuthError

func NewAuthError(technicalErr error, userMsg string) *CLIError

NewAuthError creates a CLIError for authentication failures

func NewCLIError

func NewCLIError(technicalErr error, userMsg string, exitCode ExitCode) *CLIError

NewCLIError creates a new CLIError

func NewError

func NewError(technicalErr error, userMsg string) *CLIError

NewError creates a CLIError with ExitError code

func NewNetworkError

func NewNetworkError(technicalErr error, userMsg string) *CLIError

NewNetworkError creates a CLIError for network failures

func NewUsageError

func NewUsageError(userMsg string) *CLIError

NewUsageError creates a CLIError with ExitUsageError code

func (*CLIError) Error

func (e *CLIError) Error() string

Error implements the error interface

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

Unwrap returns the underlying error

func (*CLIError) WithStackTrace

func (e *CLIError) WithStackTrace() *CLIError

WithStackTrace adds a stack trace to the error

type ExitCode

type ExitCode int

ExitCode represents CLI exit codes

const (
	// ExitSuccess indicates successful execution
	ExitSuccess ExitCode = 0
	// ExitError indicates a general error
	ExitError ExitCode = 1
	// ExitUsageError indicates invalid command usage
	ExitUsageError ExitCode = 2
	// ExitAuthError indicates an authentication error
	ExitAuthError ExitCode = 3
	// ExitNetworkError indicates a network error
	ExitNetworkError ExitCode = 4
)

Jump to

Keyboard shortcuts

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