errkit

package
v0.0.0-...-7fd672d Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(err error, errs ...error) error

Append appends one or more errors additionally to the first error. It will return nil if err is nil. It will unwrap err if it implements `interface { Unwrap() []error }` and merge the value with errs. It will merge the errors from the previous Append call in a single slice.

func ForceMarshalError

func ForceMarshalError(e error) []byte

func Join

func Join(errs ...error) error

Join merges one or more errors under the hood of a single error. nil values are discarded. It will return nil if all errors are nil or no errors were given.

func MarshalError

func MarshalError(aerr error) ([]byte, error)

func NewEquivalent

func NewEquivalent(msg string, errs ...error) error

func WithEquivalents

func WithEquivalents(err error, errs ...error) error

WithEquivalents creates a new error with equivalent errors. It wraps the given error and appends the provided equivalent errors.

func WithStack

func WithStack(err error, fields ...any) error

WithStack creates a new error with a stack trace. It wraps the given error with the stack trace.

Types

type Error

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

func WithFields

func WithFields(err error, fields ...any) *Error

func WithMessage

func WithMessage(err error, msg string, fields ...any) *Error

func Wrap

func Wrap(err error, msg string, fields ...any) *Error

func (*Error) As

func (e *Error) As(target any) bool

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithEquivalents

func (e *Error) WithEquivalents(errs ...error) *Error

func (*Error) WithField

func (e *Error) WithField(key string, value any) *Error

func (*Error) WithFields

func (e *Error) WithFields(fields ...any) *Error

type Fields

type Fields = map[string]any

func ToFields

func ToFields(fields []any) Fields

type HumanError

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

func NewHumanError

func NewHumanError(msg string, details error) *HumanError

func (*HumanError) Error

func (e *HumanError) Error() string

func (*HumanError) MarshalJSON

func (e *HumanError) MarshalJSON() ([]byte, error)

func (*HumanError) Unwrap

func (e *HumanError) Unwrap() error

Jump to

Keyboard shortcuts

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