Documentation ¶
Index ¶
- Constants
- func AddTips(err error, tips ...string) error
- func IsAny(err error, errs ...error) bool
- func IsExternalError(err error) bool
- func IsSilent(err error) bool
- func IsUserFacing(err error) bool
- func JoinMessage(err error) string
- func NewUserFacing(message string, opts ...ErrOpt) *userFacingError
- func Pack(errs ...error) error
- func ParseExitCode(err error) int
- func Silence(err error) *silencedError
- func Unpack(err error) []error
- func WrapExitCode(err error, code int) error
- func WrapUserFacing(wrapTarget error, message string, opts ...ErrOpt) *userFacingError
- type AsError
- type ErrOpt
- type ErrorTips
- type Errorable
- type ExitCode
- type ExitCodeable
- type ExternalError
- type PackedErrors
- type TransientError
- type UserFacingError
- type WrapperError
Constants ¶
const TipMessage = "wrapped tips"
Variables ¶
This section is empty.
Functions ¶
func IsExternalError ¶
func IsUserFacing ¶
func JoinMessage ¶
func NewUserFacing ¶
func Pack ¶
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 ¶
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 Unpack ¶
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 WrapUserFacing ¶
Types ¶
type ErrOpt ¶
type ErrOpt func(err *userFacingError)
type Errorable ¶
type Errorable interface { Unwrap() error Stack() *stacktrace.Stacktrace }
WrapperError enforces errors that include a stacktrace
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 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