Skip to content

Commit

Permalink
Slightly nicer error message for failed argument conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse van den Kieboom committed Sep 3, 2012
1 parent 0375c99 commit 06d68c0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions parser_private.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ func (p *Parser) parseOption(group *Group, args []string, name string, info *Inf
index
}

if err != nil && err.(*Error) == nil {
err = newError(ErrMarshal,
fmt.Sprintf("failed to marshal argument for flag `%s': %s",
info,
err.Error()))
if err != nil {
if _, ok := err.(*Error); !ok {
err = newError(ErrMarshal,
fmt.Sprintf("invalid argument for flag `%s' (expected %s)",
info,
info.value.Type()))
}
}

return err, index
Expand Down

0 comments on commit 06d68c0

Please sign in to comment.