Documentation ¶
Overview ¶
Package errors provide utility for wrapping error.
The wrapped error will have more information (stack trace and other error that cause the error).
NOTE: v1 is not maintaned anymore, please use v2
Index ¶
- Constants
- func ErrorWithCauseF(cause error, f string, v ...interface{}) error
- func Errorf(f string, v ...interface{}) error
- func Format(err error) string
- func FormatWithDeep(err error, deep int) string
- func Ignore(err error)
- func InErrorChain(err error, data interface{}) bool
- func New(data interface{}) error
- func NewWithCause(data interface{}, err error) error
- func NewWithCauseAndDeep(data interface{}, err error, deep int) error
- func PrintTo(p interface{ ... }, err error)
- func RootCause(err error) error
- func Walk(err error, fn func(*Error) bool) bool
- func Wrap(err error) error
- func WrapWithDeep(err error, deep int) error
- type Error
Constants ¶
const DefaultDeep = 20
DefaultDeep is the default deep when generating stack trace
Variables ¶
This section is empty.
Functions ¶
func ErrorWithCauseF ¶
ErrorWithCauseF is same with like ErrorF, but you can spesify the error cause
func Errorf ¶
Errorf return an Error with text according to a format specifier.
Format as specified by fmt.Sprintf
func Format ¶
Format representation of the Error, including stack trace.
Use err.Error() if you want to get just the error string
func FormatWithDeep ¶
FormatWithDeep representation of the Error, including stack trace with specified deep.
Use err.Error() if you want to get just the error string
func InErrorChain ¶
InErrorChain will return true if the data is exists in error chain
func NewWithCause ¶
NewWithCause is same with New, but it also indicate that this Error is caused by err.
func NewWithCauseAndDeep ¶
NewWithCauseAndDeep is same with NewWithCause, but with specified stack deep
func PrintTo ¶
func PrintTo(p interface{ Print(...interface{}) }, err error)
PrintTo print formated error p
func Walk ¶
Walk is helper for walk the error chains.
Walk will return true if fn is called at least once ¶
Walk will walk the chains as long fn return true
func WrapWithDeep ¶
WrapWithDeep is same with Wrap, but with specified stack deep
Types ¶
type Error ¶
type Error struct { // Data is arbitrary data attached to this error Data interface{} // Cause of this error Cause error // StackTrace where this error generated StackTrace []trace.Location }
Error represent the wrapped error
all error returned from New*, Errorf, Wrap will have type *Error