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

Method PrintOnErrorf

center_printer.go:160–171  ·  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

158// If every error is nil, nothing will be printed.
159// This can be used for simple error checking.
160func (p CenterPrinter) PrintOnErrorf(format string, a ...any) *TextPrinter {
161 for _, arg := range a {
162 if err, ok := arg.(error); ok {
163 if err != nil {
164 p.Println(fmt.Errorf(format, err))
165 }
166 }
167 }
168
169 tp := TextPrinter(p)
170 return &tp
171}

Callers

nothing calls this directly

Calls 2

PrintlnMethod · 0.95
TextPrinterInterface · 0.85

Tested by

no test coverage detected