Documentation
¶
Index ¶
- func As(err error, target interface{}) bool
- func At(err error) (string, int)
- func Cause(in error, i int) error
- func Collect(in error, pred func(error) bool) []error
- func CollectType(in, sample error) []error
- func Context(err error) *diag.Context
- func Errf(msg string, vs ...interface{}) error
- func Find(err, target error) error
- func FindIf(in error, pred func(err error) bool) error
- func FindType(in, sample error) error
- func Is(err, target error) bool
- func IsIf(err error, pred func(error) bool) bool
- func IsType(in, sample error) bool
- func Iter(in error, fn func(err error) bool)
- func New(msg string) error
- func NumCauses(in error) int
- func PredType(sample error) func(error) bool
- func Unwrap(in error) error
- func Walk(in error, fn func(error))
- func WalkEach(errs []error, fn func(error))
- func Wrap(cause error, msg string, vs ...interface{}) error
- func WrapAll(causes []error, msg string, vs ...interface{}) error
- type Builder
- func (b *Builder) Errf(msg string, vs ...interface{}) error
- func (b *Builder) With(fields ...interface{}) *Builder
- func (b *Builder) WithDiagnosticContext(ctx *diag.Context) *Builder
- func (b *Builder) WithDiagnotics(ctx context.Context) *Builder
- func (b *Builder) WithStack() *Builder
- func (b *Builder) Wrap(cause error, msg string, vs ...interface{}) error
- func (b *Builder) WrapAll(causes []error, msg string, vs ...interface{}) error
- type Frame
- type StackTrace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As finds the first error in the error tree that matches target, and if so, sets target to that error value and returns true.
An error matches target if the error's concrete value is assignable to the value pointed to by target, or if the error has a method As(interface{}) bool such that As(target) returns true. In the latter case, the As method is responsible for setting target.
As will panic if target is not a non-nil pointer to either a type that implements error, or to any interface type. As returns false if err is nil.
func CollectType ¶
CollectType returns all errors that are convertible to the error type of sample.
func Context ¶
Context returns the errors diagnostic context, if the direct error value has a context.
func Find ¶
Find walks the complete error tree, trying to find an error that matches target. The first error matching target is returned.
An error is matched with target, if the error is equal to the target, if error implements Is(error) bool that returns true for target, or target implements Is(error) bool such that Is(error) returne true.
func Is ¶
Is walks the complete error tree, trying to find an error that matches target.
An error is matched with target, if the error is equal to the target, if error implements Is(error) bool that returns true for target, or target implements Is(error) bool such that Is(error) returne true.
Use `Find` to return the actual error value that would match.
func IsIf ¶
IsIf walkt the complete error try, trying to match an error with the given predicate.
Use `FindIf` to return the actual error value that would match.
func Iter ¶
Iter iterates the complete error tree calling fn on each error value found. The user function fn can stop the iteration by returning false.
func New ¶
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 PredType ¶
PredType creates a predicate checking if the type of an error value matches the type of sample.
The predicate checks if the error type is equal or convertible to the sample type.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func WithDiagnosticContext ¶
func WithDiagnotics ¶
func (*Builder) WithDiagnosticContext ¶
type StackTrace ¶
type StackTrace []Frame
func Trace ¶
func Trace(err error) StackTrace
Trace returns the stack trace, if the error value contains one.