usageErr returns an error wrapping ErrUsage. Works like fmt.Errorf but automatically prepends the sentinel so isUserError catches it. wrapArgs wraps a Cobra positional-args validator so that its errors are tagged with ErrUsage, keeping them out of Sentry.
(fn cobra.PositionalArgs)
| 17 | // wrapArgs wraps a Cobra positional-args validator so that its errors |
| 18 | // are tagged with ErrUsage, keeping them out of Sentry. |
| 19 | func wrapArgs(fn cobra.PositionalArgs) cobra.PositionalArgs { |
| 20 | return func(cmd *cobra.Command, args []string) error { |
| 21 | if err := fn(cmd, args); err != nil { |
| 22 | return fmt.Errorf("%w: %s", ErrUsage, err) |
| 23 | } |
| 24 | return nil |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | func usageErr(format string, args ...any) error { |
| 29 | return fmt.Errorf("%w: "+format, append([]any{ErrUsage}, args...)...) |
no outgoing calls
no test coverage detected