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)
| 142 | // If every error is nil, nothing will be printed. |
| 143 | // This can be used for simple error checking. |
| 144 | func (p CenterPrinter) PrintOnError(a ...any) *TextPrinter { |
| 145 | for _, arg := range a { |
| 146 | if err, ok := arg.(error); ok { |
| 147 | if err != nil { |
| 148 | p.Println(err) |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | tp := TextPrinter(p) |
| 154 | return &tp |
| 155 | } |
| 156 | |
| 157 | // PrintOnErrorf wraps every error which is not nil and prints it. |
| 158 | // If every error is nil, nothing will be printed. |
nothing calls this directly
no test coverage detected