MCPcopy
hub / github.com/pterm/pterm / PrintOnErrorf

Method PrintOnErrorf

basic_text_printer.go:112–123  ·  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

110// If every error is nil, nothing will be printed.
111// This can be used for simple error checking.
112func (p *BasicTextPrinter) PrintOnErrorf(format string, a ...any) *TextPrinter {
113 for _, arg := range a {
114 if err, ok := arg.(error); ok {
115 if err != nil {
116 p.Println(fmt.Errorf(format, err))
117 }
118 }
119 }
120
121 tp := TextPrinter(p)
122 return &tp
123}

Callers

nothing calls this directly

Calls 2

PrintlnMethod · 0.95
TextPrinterInterface · 0.85

Tested by

no test coverage detected