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

Method Error

error.go:158–172  ·  view source on GitHub ↗

Error implements error.Error.

()

Source from the content-addressed store, hash-verified

156
157// Error implements error.Error.
158func (e *Err) Error() string {
159 // We want to walk up the stack of errors showing the annotations
160 // as long as the cause is the same.
161 err := e.previous
162 if !sameError(Cause(err), e.cause) && e.cause != nil {
163 err = e.cause
164 }
165 switch {
166 case err == nil:
167 return e.message
168 case e.message == "":
169 return err.Error()
170 }
171 return fmt.Sprintf("%s: %v", e.message, err)
172}
173
174// Format implements fmt.Formatter
175// When printing errors with %+v it also prints the stack trace.

Callers 7

FormatMethod · 0.95
TestNewErrMethod · 0.95
TestWithTypeMethod · 0.45
ErrorMethod · 0.45
DetailsFunction · 0.45
errorStackFunction · 0.45

Calls 2

sameErrorFunction · 0.85
CauseFunction · 0.85

Tested by 3

TestNewErrMethod · 0.76
TestWithTypeMethod · 0.36