config: Don't expose go implementation details in Resource.Count

Previously we would return the raw error from strconv.ParseInt, which
includes details in its text that expose implementation details and are
thus not helpful to the user.

Instead, we use a locally-defined error message that talks only about
what the caller is expected to know: that count should be parsable as
an integer.
This commit is contained in:
Martin Atkins 2018-01-17 15:21:41 -08:00
parent 48517fbab4
commit 5b08fd4f9f
1 changed files with 4 additions and 1 deletions

View File

@ -231,7 +231,10 @@ func (r *Resource) Count() (int, error) {
v, err := strconv.ParseInt(count, 0, 0)
if err != nil {
return 0, err
return 0, fmt.Errorf(
"cannot parse %q as an integer",
count,
)
}
return int(v), nil