Skip to content

Commit

Permalink
chore: improve generator errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jun 28, 2024
1 parent 6262c0b commit b1aa2ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ func main() {

file, err := os.ReadFile(filePath)
if err != nil {
log.Fatal(err)
log.Fatalf("read JSON file: %v", err)
}

var jsonModels []jsonModel
err = json.Unmarshal(file, &jsonModels)
if err != nil {
log.Fatal(err)
log.Fatalf("unmarshal file content: %v", err)
}

for _, jsonModel := range jsonModels {
Expand All @@ -175,7 +175,7 @@ func main() {

data, err := generateFileContent(cmdModel)
if err != nil {
log.Fatal(err)
log.Fatalf("generate content: %v", err)
}

genFilePath := fmt.Sprintf("../%[1]s/%[1]s_gen.go", strings.ReplaceAll(jsonModel.CommandName, "-", ""))
Expand All @@ -185,12 +185,12 @@ func main() {
// gofmt
source, err := format.Source([]byte(data))
if err != nil {
log.Fatal(err)
log.Fatalf("format source: %v", err)
}

err = os.WriteFile(genFilePath, source, 0o644)
if err != nil {
log.Fatal(err)
log.Fatalf("write file: %v", err)
}
}
}
Expand Down

0 comments on commit b1aa2ec

Please sign in to comment.