Documentation ¶
Index ¶
- Variables
- func CheckError(err error)
- func CheckErrorNoUsage(err error)
- func PanicIfError(err error)
- func PanicIfNotType(err error, types ...interface{}) error
- func PanicIfTrue(b bool, msg string, args ...interface{})
- func Try(f func(), types ...interface{}) (err error)
- func TryCatch(f func(), catch func(err error) error) (err error)
- func Unwrap(err error) error
- type Exiter
- type WrappedError
Constants ¶
This section is empty.
Variables ¶
var (
Chk = assert.New(&panicker{})
)
d.Chk.<Method>() -- used in test cases and as assertions
Functions ¶
func CheckError ¶
func CheckError(err error)
func CheckErrorNoUsage ¶
func CheckErrorNoUsage(err error)
func PanicIfError ¶
func PanicIfError(err error)
PanicIfError(err) && PanicIfTrue(expr, fmt, args) can be used to panic in a way that's easily handled by Try() and TryCatch()
func PanicIfNotType ¶
Utility method, that checks type of error and panics with wrapped error not one of the listed types.
func PanicIfTrue ¶
If b evaluates to true, creates an error using msg and args, wraps it and panics.
func Try ¶
func Try(f func(), types ...interface{}) (err error)
If 'f' panics with a WrappedError then recover that error. If types is empty, return the WrappedError. if types is not empty and cause is not one of the listed types, re-panic. if types is not empty and cause is one of the types, return 'cause'
Types ¶
type WrappedError ¶
func Wrap ¶
func Wrap(err error) WrappedError
Wraps an error. The enclosing error has a default Error() that contains the error msg along with a backtrace. The original error can be retrieved by calling err.Cause().