errs

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(err error)

Fatal logs the error and exists the program with os.Exit(1).

func Log

func Log(err error) error

Log just calls LogWith(err, log.V(log.Info)).

func LogError

func LogError(task string, err error) error

LogError is a wrapper that calls Log(NewError(task, err)).

func LogErrorWithHint added in v0.8.0

func LogErrorWithHint(task string, err error, hint string) error

LogErrorWithHint is a wrapper that calls Log(NewErrorWithHint(task, err, hint)).

func LogWith added in v0.8.0

func LogWith(err error, logger log.Logger) error

LogWith logs the given error using the given logger.

func RootCause

func RootCause(err error) error

RootCause returns the error deepest in the error chain.

Types

type Err added in v0.8.0

type Err interface {
	error
	Task() string
	Err() error
	Hint() string
}

func NewError

func NewError(task string, err error) Err

func NewErrorWithHint added in v0.8.0

func NewErrorWithHint(task string, err error, hint string) Err

func Wrap added in v0.19.0

func Wrap(task string, err error) Err

Wrap is equal to

if err == nil { return nil } else { return NewError(task, err) }

It is particularly handy to get rid of all these if statements when you want to wrap and error in Err in case the error is not nil.

Jump to

Keyboard shortcuts

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