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)
| 210 | // If every error is nil, nothing will be printed. |
| 211 | // This can be used for simple error checking. |
| 212 | func (p *HeaderPrinter) PrintOnError(a ...any) *TextPrinter { |
| 213 | for _, arg := range a { |
| 214 | if err, ok := arg.(error); ok { |
| 215 | if err != nil { |
| 216 | p.Println(err) |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | tp := TextPrinter(p) |
| 222 | return &tp |
| 223 | } |
| 224 | |
| 225 | // PrintOnErrorf wraps every error which is not nil and prints it. |
| 226 | // If every error is nil, nothing will be printed. |
nothing calls this directly
no test coverage detected