Documentation
¶
Index ¶
- func Catch(errp *error, format string, args ...interface{})
- func Errorf(format string, args ...interface{}) error
- func Join(errs ...error) error
- func New(text string) error
- func SetFormatter(f Formatter)
- func ToString(err error) string
- func Wrap(err error) error
- func WrapUp(err error) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Formatter
- type LinkedError
- type Message
- type TextFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Catch ¶ added in v1.2.1
Catch allow us to implement a different pattern of error tracing where it is the responsibility of the callee to say that it was called. This allows us to not worry about adding an message on every error return.
func (o *Something) MethodM(a TypeA) (_ Stuff, er error) { defer faults.Catch(&er, "calling MethodM(a=%v)", a) x, err := doSomething(a) // will also have a Catch() inside if err != nil { return Stuff{}, faults.Wrap(err) } s, err := stuff.New(a, x) // will also have a Catch() inside if err != nil { return Stuff{}, faults.Wrap(err) } return s, nil }
where the error message would be: "calling MethodM(a=-2): calling doSomething(a=-2): value must > 0"
func Errorf ¶
Errorf creates a new error based on format and wraps it in a stack trace. The format string can include the %w verb.
func SetFormatter ¶ added in v1.1.0
func SetFormatter(f Formatter)
Types ¶
type LinkedError ¶ added in v1.5.0
type LinkedError struct { Err error Next *LinkedError }
func (*LinkedError) As ¶ added in v1.5.0
func (e *LinkedError) As(target interface{}) bool
func (*LinkedError) Error ¶ added in v1.5.0
func (e *LinkedError) Error() string
func (*LinkedError) Is ¶ added in v1.5.0
func (e *LinkedError) Is(target error) bool
func (*LinkedError) Unwrap ¶ added in v1.5.0
func (e *LinkedError) Unwrap() error
type TextFormatter ¶ added in v1.1.0
type TextFormatter struct{}
func (TextFormatter) Format ¶ added in v1.1.0
func (TextFormatter) Format(m Message) string
Click to show internal directories.
Click to hide internal directories.