go-gorm / go-gorm/cli

fix: improve error messages in gen command

Open
#55 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
108
Forks
15
PR merge metrics
No merged PRs in 30d

Description

## Summary

Error messages in the CLI have awkward or redundant phrasing:

### 1. `internal/gen/gen.go:32`
```go
return fmt.Errorf("error render template got error: %v", err)
```
Grammatically awkward and redundant ("error...got error"). Should be:
```go
return fmt.Errorf("code generation failed: %w", err)
```

### 2. `internal/gen/gen.go:27`
```go
return fmt.Errorf("error processing %s: %v", input, err)
```
Acceptable but uses `%v` instead of `%w` for error wrapping. Should be:
```go
return fmt.Errorf("processing %s: %w", input, err)
```

### 3. `internal/gen/generator.go:192`
```go
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.