MCPcopy Create free account
hub / github.com/cockroachdb/redact / HelperForErrorf

Function HelperForErrorf

internal/rfmt/helpers.go:162–170  ·  view source on GitHub ↗

HelperForErrorf is a helper to implement a redaction-aware fmt.Errorf-compatible function in a different package. It formats the string according to the given format and arguments in the same way as Sprintf, but in addition to this if the format contains %w and an error object in the proper argument

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

Source from the content-addressed store, hash-verified

160// Note: This function only works if an error redaction function
161// has been injected with RegisterRedactErrorFn().
162func HelperForErrorf(format string, args ...interface{}) (m.RedactableString, error) {
163 p := newPrinter()
164 p.wrapErrs = true
165 p.doPrintf(format, args)
166 e := p.wrappedErr
167 s := p.buf.TakeRedactableString()
168 p.free()
169 return s, e
170}
171
172// EscapeBytes escapes markers inside the given byte slice and encloses
173// the entire byte slice between redaction markers.

Callers 1

HelperForErrorfFunction · 0.92

Calls 4

newPrinterFunction · 0.85
doPrintfMethod · 0.80
TakeRedactableStringMethod · 0.80
freeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…