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)
| 110 | // If every error is nil, nothing will be printed. |
| 111 | // This can be used for simple error checking. |
| 112 | func (p *BasicTextPrinter) PrintOnErrorf(format string, a ...any) *TextPrinter { |
| 113 | for _, arg := range a { |
| 114 | if err, ok := arg.(error); ok { |
| 115 | if err != nil { |
| 116 | p.Println(fmt.Errorf(format, err)) |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | tp := TextPrinter(p) |
| 122 | return &tp |
| 123 | } |
nothing calls this directly
no test coverage detected