Documentation
¶
Overview ¶
Package failure allows to add context, debugging information to errors.
So instead of the traditional:
if err != nil { return err }
it can be interesting to generate a new error including the initial error while giving it some context:
if err := task.Execute(); err != nil { return failure.New(err).Set("task", task.ID()).Msg("impossible to perform this task") }
It is of course possible to generate completely new errors :
if got != want { return failure.New(nil). Set("got", got). Set("want", want). Msg("the value received is not the right one") }
Index ¶
- type Failure
- func (f *Failure) Error() string
- func (f *Failure) Msg(msg string) *Failure
- func (f *Failure) Msgf(format string, args ...interface{}) *Failure
- func (f *Failure) Set(key string, value interface{}) *Failure
- func (f *Failure) Setf(key, format string, args ...interface{}) *Failure
- func (f *Failure) Unwrap() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.