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

Function NewWithDepthf

errutil/utilities.go:66–89  ·  view source on GitHub ↗

NewWithDepthf is like Newf() except the depth to capture the stack trace is configurable. See the doc of `New()` for more details.

(depth int, format string, args ...interface{})

Source from the content-addressed store, hash-verified

64// trace is configurable.
65// See the doc of `New()` for more details.
66func NewWithDepthf(depth int, format string, args ...interface{}) error {
67 // If there's the verb %w in here, shortcut to fmt.Errorf()
68 // and store the safe details as extra payload. That's
69 // because we don't want to re-implement the error wrapping
70 // logic from 'fmt' in there.
71 var err error
72 var errRefs []error
73 for _, a := range args {
74 if e, ok := a.(error); ok {
75 errRefs = append(errRefs, e)
76 }
77 }
78 redactable, wrappedErr := redact.HelperForErrorf(format, args...)
79 if wrappedErr != nil {
80 err = &withNewMessage{cause: wrappedErr, message: redactable}
81 } else {
82 err = &leafError{redactable}
83 }
84 for _, e := range errRefs {
85 err = secondary.WithSecondaryError(err, e)
86 }
87 err = withstack.WithStackDepth(err, 1+depth)
88 return err
89}
90
91// Wrap wraps an error with a message prefix.
92// A stack trace is retained.

Callers 5

NewfFunction · 0.92
NewWithDepthfFunction · 0.92
ErrorfFunction · 0.92
NewfFunction · 0.70

Calls 2

WithSecondaryErrorFunction · 0.92
WithStackDepthFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…