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{})
| 160 | // Note: This function only works if an error redaction function |
| 161 | // has been injected with RegisterRedactErrorFn(). |
| 162 | func 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. |
no test coverage detected
searching dependent graphs…