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)
| 94 | // If every error is nil, nothing will be printed. |
| 95 | // This can be used for simple error checking. |
| 96 | func (p *BasicTextPrinter) PrintOnError(a ...any) *TextPrinter { |
| 97 | for _, arg := range a { |
| 98 | if err, ok := arg.(error); ok { |
| 99 | if err != nil { |
| 100 | p.Println(err) |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | tp := TextPrinter(p) |
| 106 | return &tp |
| 107 | } |
| 108 | |
| 109 | // PrintOnErrorf wraps every error which is not nil and prints it. |
| 110 | // If every error is nil, nothing will be printed. |
nothing calls this directly
no test coverage detected