Skip to content

fix: improve error messages in gen command #55

Description

@pageton

Summary

Error messages in the CLI have awkward or redundant phrasing:

1. internal/gen/gen.go:32

return fmt.Errorf("error render template got error: %v", err)

Grammatically awkward and redundant ("error...got error"). Should be:

return fmt.Errorf("code generation failed: %w", err)

2. internal/gen/gen.go:27

return fmt.Errorf("error processing %s: %v", input, err)

Acceptable but uses %v instead of %w for error wrapping. Should be:

return fmt.Errorf("processing %s: %w", input, err)

3. internal/gen/generator.go:192

return fmt.Errorf("invalid interface %s: %w", iface.Name, iface.err)

This one is fine — shown for comparison of the preferred style.

Why

  • Consistent error message style across the codebase
  • Using %w enables callers to use errors.Is/errors.As for programmatic error handling
  • Removing redundant "error...error" phrasing makes logs easier to scan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions