errorx

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 7 Imported by: 1

README

errorx

test workflow

Intro

Extended error handling with comparable code.

Quick Start

Documents visit https://pkg.go.dev/github.com/chg1f/errorx

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Length = 1024
View Source
var Stacktrace = func() Stack { return nil }
View Source
var Unspecified = struct{}{}

Functions

func CodeOf added in v1.0.6

func CodeOf[T comparable](err error, opts ...func(*CodeOption[T])) T

func Empty added in v1.0.4

func Empty[T comparable](code T) func(*CodeOption[T])

func Errorf added in v1.0.4

func Errorf(format string, a ...any) error

func Get added in v1.0.7

func Get[T comparable](err error, key string) (any, bool)

func In added in v1.0.4

func In[T comparable](err error, codes ...T) bool

func Join added in v1.0.4

func Join(errs ...error) error

func NaN added in v1.0.4

func NaN[T comparable](code T) func(*CodeOption[T])

func New added in v1.0.4

func New(text string) error

func Wrap added in v1.0.4

func Wrap(err error) error

Types

type Builder added in v1.0.4

type Builder[T comparable] Error[T]

func Code added in v1.0.4

func Code[T comparable](code T) Builder[T]

func (Builder[T]) Errorf added in v1.0.4

func (eb Builder[T]) Errorf(format string, a ...any) error

func (Builder[T]) Join added in v1.0.4

func (eb Builder[T]) Join(errs ...error) error

func (Builder[T]) New added in v1.0.4

func (eb Builder[T]) New(msg string) error

func (Builder[T]) With added in v1.0.7

func (eb Builder[T]) With(key string, value any) Builder[T]

func (Builder[T]) Wrap added in v1.0.4

func (eb Builder[T]) Wrap(err error) error

type CodeOption added in v1.0.7

type CodeOption[T comparable] struct {
	Empty T
	NaN   T
}

type Error added in v1.0.4

type Error[T comparable] struct {
	// contains filtered or unexported fields
}

func Be added in v1.0.4

func Be[T comparable](err error) *Error[T]

func (Error[T]) Code added in v1.0.4

func (ex Error[T]) Code() T

func (*Error[T]) Error added in v1.0.4

func (ex *Error[T]) Error() string

func (*Error[T]) Get added in v1.0.7

func (ex *Error[T]) Get(key string) (any, bool)

func (*Error[T]) In added in v1.0.4

func (ex *Error[T]) In(codes ...T) bool

func (*Error[T]) Is added in v1.0.4

func (ex *Error[T]) Is(err error) bool

func (*Error[T]) Items added in v1.0.7

func (ex *Error[T]) Items() iter.Seq2[string, any]

func (*Error[T]) LogValue added in v1.0.4

func (ex *Error[T]) LogValue() slog.Value

func (*Error[T]) MarshalJSON added in v1.0.4

func (ex *Error[T]) MarshalJSON() ([]byte, error)

func (Error[T]) Stacktrace added in v1.0.4

func (ex Error[T]) Stacktrace() Stack

func (*Error[T]) String added in v1.0.4

func (ex *Error[T]) String() string

func (*Error[T]) Unwrap added in v1.0.4

func (ex *Error[T]) Unwrap() error

type Stack added in v1.0.4

type Stack interface {
	fmt.Stringer
	slog.LogValuer
	json.Marshaler
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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