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

Function Cause

functions.go:203–212  ·  view source on GitHub ↗

Cause returns the cause of the given error. This will be either the original error, or the result of a Wrap or Mask call. Cause is the usual way to diagnose errors that may have been wrapped by the other errors functions.

(err error)

Source from the content-addressed store, hash-verified

201// Cause is the usual way to diagnose errors that may have been wrapped by
202// the other errors functions.
203func Cause(err error) error {
204 var diag error
205 if err, ok := err.(causer); ok {
206 diag = err.Cause()
207 }
208 if diag != nil {
209 return diag
210 }
211 return err
212}
213
214type causer interface {
215 Cause() error

Callers 15

TestNewMethod · 0.92
TestErrorfMethod · 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
TestCauseMethod · 0.92

Calls 1

CauseMethod · 0.65

Tested by 14

TestNewMethod · 0.74
TestErrorfMethod · 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
TestCauseMethod · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…