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

Method PrintOnError

basic_text_printer.go:96–107  ·  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

94// If every error is nil, nothing will be printed.
95// This can be used for simple error checking.
96func (p *BasicTextPrinter) PrintOnError(a ...any) *TextPrinter {
97 for _, arg := range a {
98 if err, ok := arg.(error); ok {
99 if err != nil {
100 p.Println(err)
101 }
102 }
103 }
104
105 tp := TextPrinter(p)
106 return &tp
107}
108
109// PrintOnErrorf wraps every error which is not nil and prints it.
110// 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