errs

package
v0.0.0-...-b6fc690 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TipMessage = "wrapped tips"

Variables

This section is empty.

Functions

func AddTips

func AddTips(err error, tips ...string) error

func IsAny

func IsAny(err error, errs ...error) bool

func IsExternalError

func IsExternalError(err error) bool

func IsSilent

func IsSilent(err error) bool

func IsUserFacing

func IsUserFacing(err error) bool

func JoinMessage

func JoinMessage(err error) string

func NewUserFacing

func NewUserFacing(message string, opts ...ErrOpt) *userFacingError

func Pack

func Pack(errs ...error) error

Pack creates a new error that packs the given errors together, allowing for multiple errors to be returned This accepts nil errors, and will return nil if all errors passed in are also nil.

func ParseExitCode

func ParseExitCode(err error) int

ParseExitCode checks if the given error is a failure of type ExitCodeable and returns the ExitCode of the process that failed with this error

func Silence

func Silence(err error) *silencedError

func Unpack

func Unpack(err error) []error

Unpack will recursively unpack an error into a list of errors, which is useful if you need to iterate over all errors. This is similar to errors.Unwrap, but will also "unwrap" errors that are packed together, which errors.Unwrap does not.

func WrapExitCode

func WrapExitCode(err error, code int) error

func WrapUserFacing

func WrapUserFacing(wrapTarget error, message string, opts ...ErrOpt) *userFacingError

Types

type AsError

type AsError interface {
	As(interface{}) bool
}

type ErrOpt

type ErrOpt func(err *userFacingError)

func SetIf

func SetIf(evaluated bool, opt ErrOpt) ErrOpt

SetIf is a helper for setting options if some conditional evaluated to true. This is mainly intended for setting tips, as without this you'd have to evaluate your conditional outside of NewUserFacing/WrapUserFacing, adding to the boilerplate.

func SetInput

func SetInput() ErrOpt

func SetTips

func SetTips(tips ...string) ErrOpt

type ErrorTips

type ErrorTips interface {
	error
	AddTips(...string)
	ErrorTips() []string
}

type Errorable

type Errorable interface {
	Unwrap() error
	Stack() *stacktrace.Stacktrace
}

WrapperError enforces errors that include a stacktrace

type ExitCode

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

func (*ExitCode) Error

func (e *ExitCode) Error() string

func (*ExitCode) ExitCode

func (e *ExitCode) ExitCode() int

func (*ExitCode) Unwrap

func (e *ExitCode) Unwrap() error

type ExitCodeable

type ExitCodeable interface {
	ExitCode() int
}

type ExternalError

type ExternalError interface {
	ExternalError() bool
}

type PackedErrors

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

PackedErrors represents a collection of errors that aren't necessarily related to each other note that rtutils replicates this functionality to avoid import cycles

func (*PackedErrors) Error

func (e *PackedErrors) Error() string

func (*PackedErrors) IsTransient

func (e *PackedErrors) IsTransient()

func (*PackedErrors) Unwrap

func (e *PackedErrors) Unwrap() []error

type TransientError

type TransientError interface {
	IsTransient()
}

TransientError represents an error that is transient, meaning it does not itself represent a failure, but rather it facilitates a mechanic meant to get to the actual error (eg. by wrapping or packing underlying errors). Do NOT satisfy this interface for errors whose type you want to assert.

type UserFacingError

type UserFacingError interface {
	error
	UserError() string
}

type WrapperError

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

WrapperError is what we use for errors created from this package, this does not mean every error returned from this package is wrapping something, it simply has the plumbing to.

func New

func New(message string, args ...interface{}) *WrapperError

New creates a new error, similar to errors.New

func Wrap

func Wrap(wrapTarget error, message string, args ...interface{}) *WrapperError

Wrap creates a new error that wraps the given error

func (*WrapperError) AddTips

func (e *WrapperError) AddTips(tips ...string)

func (*WrapperError) Error

func (e *WrapperError) Error() string

func (*WrapperError) ErrorTips

func (e *WrapperError) ErrorTips() []string

func (*WrapperError) Stack

func (e *WrapperError) Stack() *stacktrace.Stacktrace

Stack returns the stacktrace for where this error was created

func (*WrapperError) Unwrap

func (e *WrapperError) Unwrap() error

Unwrap returns the parent error, if one exists

Jump to

Keyboard shortcuts

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