formatMessage applies fmt.Sprintf only when args are present, so a caller passing a literal message with a stray "%" (e.g. "disk 100% full") is not rendered as "%!(NOVERB)". `go vet -printf` catches most accidental format misuse upstream; this guard makes the constructor safe even when the message s
(format string, args []any)
| 14 | // format misuse upstream; this guard makes the constructor safe even when |
| 15 | // the message string is dynamically composed. |
| 16 | func formatMessage(format string, args []any) string { |
| 17 | if len(args) == 0 { |
| 18 | return format |
| 19 | } |
| 20 | return fmt.Sprintf(format, args...) |
| 21 | } |
| 22 | |
| 23 | // Typed error types and their builder APIs. |
| 24 | // |
no outgoing calls
no test coverage detected