MCPcopy
hub / github.com/pterm/pterm / PrintOnError

Method PrintOnError

center_printer.go:144–155  ·  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

142// If every error is nil, nothing will be printed.
143// This can be used for simple error checking.
144func (p CenterPrinter) PrintOnError(a ...any) *TextPrinter {
145 for _, arg := range a {
146 if err, ok := arg.(error); ok {
147 if err != nil {
148 p.Println(err)
149 }
150 }
151 }
152
153 tp := TextPrinter(p)
154 return &tp
155}
156
157// PrintOnErrorf wraps every error which is not nil and prints it.
158// 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