Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Check = CheckFunc(func(err error, args ...error) error { if err == nil { return nil } err = Wrap.With(args...)(err) return Throw(err) })
Check is for error checking. if err is not nil, it will be wrapped with args then raised by Throw
var Wrap = WrapFunc(func(err error) error {
return err
})
var WrapStacktrace = WrapFunc(func(prev error) error { if prev == nil { return nil } if stacktraceIncluded(prev) { return prev } var pcs _PCs runtime.Callers(2, pcs[:]) stacktrace := &Stacktrace{ handle: unique.Make(pcs), } err := Join(stacktrace, prev) return err })
WrapStacktrace wraps current stacktrace
Functions ¶
func Handle ¶
Handle is for error handling
Error raised by Throw will be catched if any. If errp point to non-nil error, the error will be joined. If the result error is not nil, wrap functions will be applied. The result error will be assigned to errp if errp is not nil, otherwise Throw will be raised.
func TestWrapFunc ¶
TestWrapFunc tests a WrapFunc instance
Types ¶
type CheckFunc ¶
CheckFunc is the type of Check, see Check's doc for details
type ErrInfo ¶
type ErrInfo struct {
// contains filtered or unexported fields
}
ErrInfo represents a lazy-evaluaed formatted string
type Error ¶
type Error []error
Error represents multiple errors
func (Error) As ¶
As reports whether any error in the slice matches target. And if so, assign the first matching error to target
type Stacktrace ¶
type Stacktrace struct {
// contains filtered or unexported fields
}
Stacktrace represents call stack frames
func (*Stacktrace) Is ¶
func (s *Stacktrace) Is(err error) bool
type WrapFunc ¶
WrapFunc wraps an error to form a new one.
Instances must follow these rules: if argument is nil, return value must be nil
func IgnoreContains ¶
IgnoreContains returns a WrapFunc that returns nil if prev.Error() contains str
func TestingFatal ¶
TestingFatal returns a WrapFunc that calls t.Fatal if error occur