MCPcopy Index your code
hub / github.com/go-errors/errors / New

Function New

error.go:71–87  ·  view source on GitHub ↗

New makes an Error from the given value. If that value is already an error then it will be used directly, if not, it will be passed to fmt.Errorf("%v"). The stacktrace will point to the line of code that called New.

(e interface{})

Source from the content-addressed store, hash-verified

69// fmt.Errorf("%v"). The stacktrace will point to the line of code that
70// called New.
71func New(e interface{}) *Error {
72 var err error
73
74 switch e := e.(type) {
75 case error:
76 err = e
77 default:
78 err = fmt.Errorf("%v", e)
79 }
80
81 stack := make([]uintptr, MaxStackDepth)
82 length := runtime.Callers(2, stack[:])
83 return &Error{
84 Err: err,
85 stack: stack[:length],
86 }
87}
88
89// Wrap makes an Error from the given value. If that value is already an
90// error then it will be used directly, if not, it will be passed to

Callers 5

TestIs113Function · 0.85
SourceLineMethod · 0.85
TestNewFunction · 0.85
TestIsFunction · 0.85
ExampleNewFunction · 0.85

Calls 1

CallersMethod · 0.80

Tested by 4

TestIs113Function · 0.68
TestNewFunction · 0.68
TestIsFunction · 0.68
ExampleNewFunction · 0.68