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

Method finishDisplay

errbase/format_error.go:596–624  ·  view source on GitHub ↗

finishDisplay renders s.finalBuf into s.State.

(verb rune)

Source from the content-addressed store, hash-verified

594
595// finishDisplay renders s.finalBuf into s.State.
596func (p *state) finishDisplay(verb rune) {
597 if p.redactableOutput {
598 // If we're rendering in redactable form, then s.finalBuf contains
599 // a RedactableBytes. We can emit that directly.
600 sp := p.State.(redact.SafePrinter)
601 sp.Print(redact.RedactableBytes(p.finalBuf.Bytes()))
602 return
603 }
604 // Not redactable: render depending on flags and verb.
605
606 width, okW := p.Width()
607 _, okP := p.Precision()
608
609 // If `direct` is set to false, then the buffer is always
610 // passed through fmt.Printf regardless of the width and alignment
611 // settings. This is important for e.g. %q where quotes must be added
612 // in any case.
613 // If `direct` is set to true, then the detour via
614 // fmt.Printf only occurs if there is a width or alignment
615 // specifier.
616 direct := verb == 'v' || verb == 's'
617
618 if !direct || (okW && width > 0) || okP {
619 _, format := redact.MakeFormat(p, verb)
620 fmt.Fprintf(p.State, format, p.finalBuf.String())
621 } else {
622 io.Copy(p.State, &p.finalBuf)
623 }
624}
625
626var detailSep = []byte("\n | ")
627

Callers 1

formatErrorInternalFunction · 0.95

Calls 2

PrintMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected