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)
| 226 | // If every error is nil, nothing will be printed. |
| 227 | // This can be used for simple error checking. |
| 228 | func (p *HeaderPrinter) PrintOnErrorf(format string, a ...any) *TextPrinter { |
| 229 | for _, arg := range a { |
| 230 | if err, ok := arg.(error); ok { |
| 231 | if err != nil { |
| 232 | p.Println(fmt.Errorf(format, err)) |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | tp := TextPrinter(p) |
| 238 | return &tp |
| 239 | } |
nothing calls this directly
no test coverage detected