Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/schematic/schematic.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func main() {
var s schematic.Schema
d := json.NewDecoder(i)
if err := d.Decode(&s); err != nil {
log.Fatal(err)
log.Fatal(fmt.Errorf("Error decoding schema JSON: %w", err))
}

code, err := s.Generate()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", code)
log.Fatal(err)
log.Fatal(fmt.Errorf("Error generating Go code (output above): %w", err))
}

fmt.Fprintln(o, string(code))
Expand Down
4 changes: 2 additions & 2 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *Schema) Generate() ([]byte, error) {
}

if !context.Definition.AreTitleLinksUnique() {
return nil, fmt.Errorf("duplicate titles detected for %s", context.Name)
return nil, fmt.Errorf("Duplicate %s.links.title detected in the schema. Links must have distinct titles.", context.Name)
}

templates.ExecuteTemplate(&buf, "struct.tmpl", context)
Expand All @@ -88,7 +88,7 @@ func (s *Schema) Generate() ([]byte, error) {
// Format sources
clean, err := format.Source(bytes)
if err != nil {
return buf.Bytes(), err
return bytes, fmt.Errorf("Error formatting Go source: %w", err)
}
return clean, nil
}
Expand Down