errors

package
v0.0.0-...-ba6715f Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllAnnotated

func AllAnnotated(err error) iter.Seq[AnnotatedError]

AllAnnotated returns an iterator that iterates over all the AnnotatedError in err.

func As

func As(err error, target any) bool

As exposes stdlib errors.As.

func DecoratePanic

func DecoratePanic(excp any) error

DecoratePanic returns an annotated error with the stack trace of the panic.

func Is

func Is(err, target error) bool

Is exposes stdlib errors.Is.

func Join

func Join(errs ...error) error

Join exposes stdlib errors.Join.

func NewSentinel

func NewSentinel(msg string) error

NewSentinel creates a plain error without other context that can be used as sentinel error that can be detected with errors.Is.

func SlogError

func SlogError(err error) slog.Attr

SlogError compiles the annotations to a slog.Attr for logging.

func Unwrap

func Unwrap(err error) error

Unwrap exposes stdlib errors.Unwrap.

func Wrap

func Wrap(err error, msg string, attrs ...slog.Attr) error

Wrap is a convenience function for wrapping errors, e.g., adding context to a sentinel error.

Types

type AnnotatedError

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

AnnotatedError includes more context than a plain error that is useful for troubleshooting.

func New

func New(msg string, attrs ...slog.Attr) AnnotatedError

New creates a new AnnotatedError with the given message and attributes.

func (AnnotatedError) Error

func (err AnnotatedError) Error() string

Error implements error interface.

Jump to

Keyboard shortcuts

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