Skip to content

Commit

Permalink
errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aghull committed Mar 23, 2024
1 parent 4418af2 commit 1e8f1a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/bz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (b *bz) run() error {
// Add a path.
manifest, err := devBuilder.Manifest()
if err != nil {
log.Fatal(fmt.Errorf("error getting manifest: %w", err))
log.Fatal(fmt.Errorf("Error getting manifest json\n\n%w", err))
}
server, err := devtools.NewServer(gameRoot, manifest, *port)
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions internal/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ func (b *Builder) WatchedFiles() ([]string, error) {
}

func (b *Builder) Manifest() (*ManifestV1, error) {
f, err := os.Open(path.Join(b.root, "game.v1.json"))
manifestFile := "game.v1.json"
f, err := os.Open(path.Join(b.root, manifestFile))
if err != nil {
if os.IsNotExist(err) {
f, err = os.Open(path.Join(b.root, "game.json"))
manifestFile := "game.json"
f, err = os.Open(path.Join(b.root, manifestFile))
if err != nil {
return nil, err
return nil, fmt.Errorf("Cound not find game.json or game.v1.json")
}
} else {
return nil, err
Expand All @@ -145,7 +147,7 @@ func (b *Builder) Manifest() (*ManifestV1, error) {
defer f.Close()
manifest := &ManifestV1{}
if err := json.NewDecoder(f).Decode(manifest); err != nil {
return nil, err
return nil, fmt.Errorf("Unable to parse %s. See example at https://github.com/boardzilla/boardzilla-empty-game/blob/main/game.json\n %s", manifestFile, err)
}
return manifest, nil
}
Expand Down

0 comments on commit 1e8f1a6

Please sign in to comment.