From 5b08fd4f9f54793faff1edd5a46daa89fbb0e9a2 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 17 Jan 2018 15:21:41 -0800 Subject: [PATCH] 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. --- config/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 055a7f330..1772fd7e3 100644 --- a/config/config.go +++ b/config/config.go @@ -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