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)
| 158 | // If every error is nil, nothing will be printed. |
| 159 | // This can be used for simple error checking. |
| 160 | func (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 | } |
nothing calls this directly
no test coverage detected