Documentation ¶
Overview ¶
Package d implements several debug, error and assertion functions used throughout Noms.
Index ¶
- Variables
- func CheckError(err error)
- func CheckErrorNoUsage(err error)
- func Panic(format string, args ...interface{})
- func PanicIfError(err error)
- func PanicIfFalse(b bool)
- func PanicIfNotType(err error, types ...interface{}) error
- func PanicIfTrue(b bool)
- 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 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 Panic ¶
func Panic(format string, args ...interface{})
Panic(err) creates an error using format and args and wraps it in a WrappedError which can be handled using Try() and TryCatch()
func PanicIfError ¶
func PanicIfError(err error)
PanicIfError(err) && PanicIfTrue(expr) can be used to panic in a way that's easily handled by Try() and TryCatch()
func PanicIfFalse ¶
func PanicIfFalse(b bool)
If b is false, creates a default error, wraps it and panics.
func PanicIfNotType ¶
Utility method, that checks type of error and panics with wrapped error not one of the listed types.
func PanicIfTrue ¶
func PanicIfTrue(b bool)
If b is true, creates a default error, 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().