From 2c54dab85345816dc81287034dc356e843e93cae Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Tue, 31 Oct 2017 10:02:14 +0900 Subject: [PATCH] add more informative error messages when calling strconv.Atoi fails --- check/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check/utils.go b/check/utils.go index d9249f4..cd5127e 100644 --- a/check/utils.go +++ b/check/utils.go @@ -107,7 +107,7 @@ func lineCount(filepath string) (int, error) { // wc output is like: 999 filename.go count, err := strconv.Atoi(strings.Split(strings.TrimSpace(string(out)), " ")[0]) if err != nil { - return 0, err + return 0, fmt.Errorf("could not count lines: %v", err) } return count, nil @@ -162,7 +162,7 @@ func (fs *FileSummary) AddError(out string) error { ls := strings.Split(s[1], ":") ln, err := strconv.Atoi(ls[0]) if err != nil { - return err + return fmt.Errorf("AddError: could not parse %q - %v", out, err) } e.LineNumber = ln