newInvalidArgumentError creates a standardized error for an invalid single argument
(ctx context.Context, key, arg string, expected ...string)
| 86 | |
| 87 | // newInvalidArgumentError creates a standardized error for an invalid single argument |
| 88 | func newInvalidArgumentError(ctx context.Context, key, arg string, expected ...string) error { |
| 89 | msg := "Invalid %s: %s" |
| 90 | if len(expected) > 0 { |
| 91 | msg += " (expected " + strings.Join(expected, ", ") + ")" |
| 92 | } |
| 93 | |
| 94 | return newOptionArgumentError(ctx, key, msg, key, arg) |
| 95 | } |
| 96 | |
| 97 | func errorKey(key string) string { |
| 98 | k, _, _ := strings.Cut(strings.ReplaceAll(key, "_", "-"), ".") |
no test coverage detected