d

package
v0.0.0-...-22f70f5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package d implements several debug, error and assertion functions used throughout Noms.

Index

Constants

This section is empty.

Variables

View Source
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

func PanicIfNotType(err error, types ...interface{}) error

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'

func TryCatch

func TryCatch(f func(), catch func(err error) error) (err error)

If 'f' panics with a WrappedError then recover that error and return it. 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'

func Unwrap

func Unwrap(err error) error

If err is a WrappedError, then Cause() is returned, otherwise returns err.

Types

type WrappedError

type WrappedError interface {
	Error() string
	Cause() error
}

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().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL