(source error, msg string, args ...any)
| 52 | } |
| 53 | |
| 54 | func WithUserMessage(source error, msg string, args ...any) error { |
| 55 | // We don't want to wrap the error if it already has a user message. Doing |
| 56 | // so would obscure the original error message which is likely more useful. |
| 57 | if source == nil || hasUserMessage(source) { |
| 58 | return source |
| 59 | } |
| 60 | return &combined{ |
| 61 | source: source, |
| 62 | userMessage: fmt.Sprintf(msg, args...), |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func WithLoggedUserMessage(source error, msg string, args ...any) error { |
| 67 | if source == nil || hasUserMessage(source) { |
no test coverage detected