MCPcopy Index your code
hub / github.com/cockroachdb/errors / UnwrapOnce

Function UnwrapOnce

errbase/unwrap.go:40–48  ·  view source on GitHub ↗

Sadly the go 2/1.13 design for errors has promoted the name `Unwrap()` for the method that accesses the cause, whilst the ecosystem has already chosen `Cause()`. In order to unwrap reliably, we must thus support both. See: https://github.com/golang/go/issues/31778 UnwrapOnce accesses the direct cau

(err error)

Source from the content-addressed store, hash-verified

38// The go stdlib does not define output on `Unwrap()` for a multi-cause
39// error, so we default to nil here.
40func UnwrapOnce(err error) (cause error) {
41 switch e := err.(type) {
42 case interface{ Cause() error }:
43 return e.Cause()
44 case interface{ Unwrap() error }:
45 return e.Unwrap()
46 }
47 return nil
48}
49
50// UnwrapAll accesses the root cause object of the error.
51// If the error has no cause (leaf error), it is returned directly.

Callers 15

UnwrapFunction · 0.92
UnwrapOnceFunction · 0.92
GetContextTagsFunction · 0.92
SafeDetailsMethod · 0.92
IsFunction · 0.92
isMarkEqualFunction · 0.92
IfFunction · 0.92
getMarkFunction · 0.92
GetDomainFunction · 0.92
GetAllIssueLinksFunction · 0.92
SafeDetailsMethod · 0.92
TestUnwrapFunction · 0.92

Calls 2

UnwrapMethod · 0.65
CauseMethod · 0.45

Tested by 4

TestUnwrapFunction · 0.74
TestMixedErrorWrappingFunction · 0.74
TestMultiErrorUnwrapFunction · 0.74
TestSimplifyStacksFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…