errors

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorRetriable = errors.New("retryable error")
)

Functions

func Is

func Is(err, target error) bool

Is checks if the given error is the same as the target error It is a wrapper around errors.Is

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks if the given error is a retryable error

func NewRetryableError

func NewRetryableError(err error) error

NewRetryableError wraps the given error with a retryable error

Types

type Error

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

Error indicates an error with more features like metedata

func New

func New(message string) *Error

New returns an error that formats as the given text. Each call to New returns a distinct error value even if the text is identical.

func WithStack

func WithStack(err error) *Error

WithStack annotates err with a stack trace at the point WithStack is called, and returns the result. If err is nil, WithStack returns nil.

func Wrap

func Wrap(err error, message string) *Error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.

func Wrapf

func Wrapf(err error, format string, args ...any) *Error

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. If err is nil, Wrapf returns nil.

func (*Error) Error

func (er *Error) Error() string

Error returns the error message. and adds the metadata to the error message

func (Error) Format

func (er Error) Format(s fmt.State, verb rune)

Format implements fmt.Formatter. It supports the formats %+v, %v, %s and %q. %+v prints the error message and the stack trace. %v and %s print the error message. %q prints the error message in quotes.

func (*Error) Is

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

func (Error) Metadata

func (e Error) Metadata() map[string]string

MetaData returns copy of error metadata . Since it is copied no trace issue needs to be worried about

func (Error) MetadataString

func (er Error) MetadataString() string

MetadataString returns the metadata as a string if there is no metadata it returns an empty string if there is metadata it returns a string with the format key1: value1,key2: value2, ...

func (*Error) Unwrap

func (er *Error) Unwrap() error

Unwrap returns the underlying error. If the error is nil or does not implement Unwrap, Unwrap returns nil. Unwrap is implemented by all errors returned by this package. It is used by errors.Is and errors.As to check for a specific error (or target) in a Tree of errors.

func (Error) WithField

func (err Error) WithField(field, value string) *Error

WithField adds a field to the error metadata and returns a new error

Jump to

Keyboard shortcuts

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