Skip to content

Commit

Permalink
fix error message when main() is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
katakonst committed Jan 7, 2018
1 parent b6bb4e1 commit 573e9a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func Run(cfg *Config) (result string, err error) {
})
if err != nil {
return result, errors.Wrapf(err, "unable to compile file")
} else if len(files) == 0 {
return result, fmt.Errorf("a main file requires a main function to build")
} else if len(files) != 1 {
return result, fmt.Errorf("joy run expects only 1 main file, but received %d files", len(files))
}
Expand Down
2 changes: 2 additions & 0 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func Run(ctx context.Context, ver string) (err error) {
})
if err != nil {
return errors.Wrapf(err, "error building code")
} else if len(files) == 0 {
return fmt.Errorf("a main file requires a main function to build")
} else if len(files) != 1 {
return fmt.Errorf("joy run expects only 1 main file, but received %d files", len(files))
}
Expand Down

0 comments on commit 573e9a7

Please sign in to comment.