errorutil

package
v0.0.0-...-009ad45 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Callers

func Callers(depth int) []string

func Partition

func Partition(err error, predicate func(err error) bool) (matched error, notMatched error)

Partition takes a predicate and an error, and returns a pair of joined errors of which do and do not satisfy the predicate, respectively

Example usage

   matched, notMatched := Partition(someJoinedErr, func(err error) bool {
	   return errors.Is(err, errA)
	 })

	 if errors.Is(matched, errA) {
		 ...
	 }

func Summary

func Summary(err error) string

func Unwrap

func Unwrap(err error, visitor func(err error))

Unwrap unwraps err. It DOES NOT use errors.Unwrap and handles errors.Join.

func WithDetails

func WithDetails(err error, d Details) error

func WithSecondaryError

func WithSecondaryError(err, serr error) error

Types

type DetailTag

type DetailTag string
const (
	SafeDetail DetailTag = "safe"
)

func (DetailTag) Value

func (t DetailTag) Value(value interface{}) DetailTaggedValue

type DetailTaggedValue

type DetailTaggedValue struct {
	Tag   DetailTag
	Value interface{}
}

func (DetailTaggedValue) MarshalText

func (tv DetailTaggedValue) MarshalText() ([]byte, error)

type Detailer

type Detailer interface {
	error
	FillDetails(d Details)
}

type Details

type Details map[string]interface{}

func CollectDetails

func CollectDetails(err error, d Details) Details

func FilterDetails

func FilterDetails(d Details, tag DetailTag) Details

func GetSafeDetails

func GetSafeDetails(err error) Details

type Stacker

type Stacker interface {
	Stack() string
}

Jump to

Keyboard shortcuts

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