Documentation ¶
Overview ¶
Package errutil provides utilities for easily annotating Go errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Annotatef ¶
Annotatef annotates non-nil error with the given message.
It's designed to be used in a defer, for example:
func g(arg string) (err error) { defer Annotate(&err, fmt.Sprintf("g(%s)") return errors.New("my error") }
Calling g("hello") will result in error message:
g(hello): my error
Annotate allows using the above short form instead of the long form:
func g(arg string) (err error) { defer func() { if err != nil { err = fmt.Errorf("g(%s): %v", arg, err) } }() return errors.New("my error") }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.