merr

package
v0.0.0-...-81f452b Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCode

func IsCode(err error, code Code) bool

IsCode is a convenience wrapper for `errors.Is`

`errors.Is(err, "foo")` does not work

`IsCode(err, "foo")` does - as the string is automatically converted

Types

type Code

type Code string

func (Code) Error

func (c Code) Error() string

func (Code) String

func (c Code) String() string

type E

type E struct {
	Code Code `json:"code"`
	Meta M    `json:"meta"`

	TraceID trace.TraceID `json:"trace_id"`
	SpanID  trace.SpanID  `json:"span_id"`

	Stack []stacktrace.Frame `json:"stack"`

	Reasons []error `json:"reasons"`
}

func New

func New(ctx context.Context, code Code, meta M, reasons ...error) E

func (E) Equal

func (e E) Equal(e2 E) bool

func (E) Error

func (e E) Error() string

Error implements the error interface

Provides a simple string representation of the error, but cannot include the complete data contained in the error

No compatibility guarantees are made with its output - it may change at any time

func (E) Fields

func (e E) Fields() map[string]any

func (E) Is

func (e E) Is(err error) bool

Is enables the use of `errors.Is`

func (E) Merr

func (e E) Merr() E

func (E) String

func (e E) String() string

func (E) Unwrap

func (e E) Unwrap() []error

Unwrap enables the use of `errors.Unwrap`

type M

type M map[string]any

type Merrer

type Merrer interface {
	error
	Merr() E
}

Merrer (merr-er) represents a merr-compatible error

It primarily exists to allow `Wrap` to return nil without forcing us to use pointers for `E`, but also allows other structs to offer a merr.E option

Jump to

Keyboard shortcuts

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