MCPcopy Index your code
hub / github.com/pterm/pterm / PrintOnErrorf

Method PrintOnErrorf

header_printer.go:228–239  ·  view source on GitHub ↗

PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.

(format string, a ...any)

Source from the content-addressed store, hash-verified

226// If every error is nil, nothing will be printed.
227// This can be used for simple error checking.
228func (p *HeaderPrinter) PrintOnErrorf(format string, a ...any) *TextPrinter {
229 for _, arg := range a {
230 if err, ok := arg.(error); ok {
231 if err != nil {
232 p.Println(fmt.Errorf(format, err))
233 }
234 }
235 }
236
237 tp := TextPrinter(p)
238 return &tp
239}

Callers

nothing calls this directly

Calls 2

PrintlnMethod · 0.95
TextPrinterInterface · 0.85

Tested by

no test coverage detected