Documentation
¶
Index ¶
- Constants
- func As(err error, target any) bool
- func AsA[T any](err error) (*T, bool)
- func DebugPrint(err error)
- func ErrJsonify(err error) map[string]any
- func ErrStringify(buf *bytes.Buffer, err error)
- func Errorf(msg string, args ...any) error
- func FormatChain(err error) string
- func FullMessage(err error) string
- func GetErrorId(err error) string
- func IfErr(err error, fn func(err error) error) error
- func Is(err, target error) bool
- func Join(errs ...error) error
- func JsonPrint(err error) []byte
- func MarshalError(err error) ([]byte, error)
- func New(msg string, tags ...Tags) error
- func NewErrorId() string
- func PrintFormat(f fmt.State, verb rune, err Error)
- func RootCause(err error) error
- func Unwrap(err error) error
- func Walk(err error, fn func(error) bool)
- func Wrap(err error, msg string) error
- func WrapCaller(err error, skip ...int) error
- func WrapFn(err error, tagsFn ...func() Tags) error
- func WrapKV(err error, key string, value any) error
- func WrapStack(err error) error
- func WrapTags(err error, tags ...Tags) error
- func WrapTagsCaller(err error, tags Tags, skip ...int) error
- func Wrapf(err error, format string, args ...any) error
- type Err
- type ErrAs
- type ErrIs
- type ErrUnwrapper
- type ErrWrap
- type Error
- type ErrorID
- type Tags
Constants ¶
View Source
const (
// TagKeyMessage is the wrap-layer context key populated by Wrap and New.
TagKeyMessage = "msg"
)
Variables ¶
This section is empty.
Functions ¶
func DebugPrint ¶
func DebugPrint(err error)
func ErrJsonify ¶
func ErrStringify ¶
func FormatChain ¶ added in v2.0.5
FormatChain returns a human-readable error chain joined with ": ". Wrap context from ErrWrap tags is included while duplicate adjacent messages are omitted.
func FullMessage ¶ added in v2.0.5
FullMessage is an alias for FormatChain.
func GetErrorId ¶
func MarshalError ¶ added in v2.0.5
func NewErrorId ¶
func NewErrorId() string
func Walk ¶ added in v2.0.5
Walk traverses the error chain from outer to inner. Returning false from fn stops traversal.
func WrapCaller ¶
Types ¶
type Err ¶
type Err struct {
Msg string `json:"msg,omitempty"`
Detail string `json:"detail,omitempty"`
Tags Tags `json:"tags,omitempty"`
// contains filtered or unexported fields
}
func (Err) MarshalJSON ¶
type ErrUnwrapper ¶
type ErrUnwrapper interface {
Unwrap() error
}
type ErrWrap ¶
type ErrWrap struct {
Err error
Tags Tags
Caller string
Stacks []string
// contains filtered or unexported fields
}
func (*ErrWrap) MarshalJSON ¶
type Tags ¶
func CollectTags ¶ added in v2.0.5
CollectTags merges tags from every *Err and *ErrWrap layer in the chain. Outer layers win when keys conflict.
func CollectUserTags ¶ added in v2.0.5
CollectUserTags returns merged user tags from the error chain. System wrap context stored under TagKeyMessage is excluded.
func GetTags ¶ added in v2.0.5
GetTags returns tags from the innermost *Err in the chain. When no *Err carries tags, it falls back to the outermost layer tags.
func (Tags) ToMapString ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.