MCPcopy Create free account
hub / github.com/juju/errors / New

Function New

functions.go:19–23  ·  view source on GitHub ↗

New is a drop in replacement for the standard library errors module that records the location that the error is created. For example: return errors.New("validation failed")

(message string)

Source from the content-addressed store, hash-verified

17// return errors.New("validation failed")
18//
19func New(message string) error {
20 err := &Err{message: message}
21 err.SetLocation(1)
22 return err
23}
24
25// Errorf creates a new annotated error and records the location that the
26// error is created. This should be a drop in replacement for fmt.Errorf.

Callers 15

TestNewMethod · 0.92
TestTraceMethod · 0.92
TestAnnotateMethod · 0.92
TestAnnotatefMethod · 0.92
TestDeferredAnnotatefMethod · 0.92
TestWrapMethod · 0.92
TestWrapOfNilMethod · 0.92
TestWrapfMethod · 0.92
TestWrapfOfNilMethod · 0.92
TestMaskMethod · 0.92
TestMaskfMethod · 0.92
TestErrorStackMethod · 0.92

Calls 1

SetLocationMethod · 0.95

Tested by 15

TestNewMethod · 0.74
TestTraceMethod · 0.74
TestAnnotateMethod · 0.74
TestAnnotatefMethod · 0.74
TestDeferredAnnotatefMethod · 0.74
TestWrapMethod · 0.74
TestWrapOfNilMethod · 0.74
TestWrapfMethod · 0.74
TestWrapfOfNilMethod · 0.74
TestMaskMethod · 0.74
TestMaskfMethod · 0.74
TestErrorStackMethod · 0.74