Categorygithub.com/marmotedu/errors
modulepackage
1.0.2
Repository: https://github.com/marmotedu/errors.git
Documentation: pkg.go.dev

# README

基于 github.com/pkg/errors 包,增加对 error code 的支持,完全兼容 github.com/pkg/errors

性能跟 github.com/pkg/errors 基本持平。

该 errors 包匹配的错误码设计请参考:marmotedu/sample-code

# Functions

AggregateGoroutines runs the provided functions in parallel, stuffing all non-nil errors into the returned Aggregate.
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
Cause returns the underlying cause of the error, if possible.
CreateAggregateFromMessageCountMap converts MessageCountMap Aggregate.
Errorf formats according to a format specifier and returns the string as a value that satisfies error.
FilterOut removes all errors that match any of the matchers from the input error.
Flatten takes an Aggregate, which may hold other Aggregates in arbitrary nesting, and flattens them all into a single Aggregate, recursively.
Is reports whether any error in err's chain matches target.
IsCode reports whether any error in err's chain contains the given error code.
MustRegister register a user define error code.
New returns an error with the supplied message.
NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface.
NewString creates a String from a list of values.
ParseCoder parse any error into *withCode.
Reduce will return err or, if err is an Aggregate and only has one item, the first item in the aggregate.
Register register a user define error code.
StringKeySet creates a String from a keys of a map[string](? extends interface{}).
Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error.
No description provided by the author
WithMessage annotates err with a new message.
WithMessagef annotates err with the format specifier.
WithStack annotates err with a stack trace at the point WithStack was called.
Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message.
No description provided by the author
Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier.

# Variables

ErrPreconditionViolated is returned when the precondition is violated.

# Structs

Empty is public since it is used by some internal API objects for conversions between external string arrays and internal sets, and conversion logic requires public types today.

# Interfaces

Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning.
Coder defines an interface for an error code detail information.

# Type aliases

Frame represents a program counter inside a stack frame.
Matcher is used to match errors.
MessageCountMap contains occurrence for each error message.
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
String is a set of strings, implemented via map[string]struct{} for minimal memory consumption.