MCPcopy Create free account
hub / github.com/pterm/pterm / PrintOnError

Method PrintOnError

header_printer.go:212–223  ·  view source on GitHub ↗

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

(a ...any)

Source from the content-addressed store, hash-verified

210// If every error is nil, nothing will be printed.
211// This can be used for simple error checking.
212func (p *HeaderPrinter) PrintOnError(a ...any) *TextPrinter {
213 for _, arg := range a {
214 if err, ok := arg.(error); ok {
215 if err != nil {
216 p.Println(err)
217 }
218 }
219 }
220
221 tp := TextPrinter(p)
222 return &tp
223}
224
225// PrintOnErrorf wraps every error which is not nil and prints it.
226// If every error is nil, nothing will be printed.

Callers

nothing calls this directly

Calls 2

PrintlnMethod · 0.95
TextPrinterInterface · 0.85

Tested by

no test coverage detected