diff --git a/errors.go b/errors.go index 81d8292..ced1d9c 100644 --- a/errors.go +++ b/errors.go @@ -5,9 +5,9 @@ import ( "reflect" ) -// TypeError is an error type returned when param has difficulty deserializing a -// parameter value. -type TypeError struct { +// ValueError is an error type returned when param has difficulty deserializing +// a parameter value. +type ValueError struct { // The key that was in error. Key string // The type that was expected. @@ -17,9 +17,9 @@ type TypeError struct { Err error } -func (t TypeError) Error() string { - return fmt.Sprintf("param: error parsing key %q as %v: %v", t.Key, t.Type, - t.Err) +func (v ValueError) Error() string { + return fmt.Sprintf("param: error parsing key %q as %v: %v", + v.Key, v.Type, v.Err) } // SingletonError is an error type returned when a parameter is passed multiple diff --git a/parse.go b/parse.go index 3050c48..960c873 100644 --- a/parse.go +++ b/parse.go @@ -108,7 +108,7 @@ func parseTextUnmarshaler(key, keytail string, values []string, target reflect.V tu := target.Addr().Interface().(encoding.TextUnmarshaler) err = tu.UnmarshalText([]byte(values[0])) if err != nil { - return TypeError{ + return ValueError{ Key: kpath(key, keytail), Type: target.Type(), Err: err, @@ -132,7 +132,7 @@ func parseBool(key, keytail string, values []string, target reflect.Value) error target.SetBool(false) return nil default: - return TypeError{ + return ValueError{ Key: kpath(key, keytail), Type: target.Type(), } @@ -148,7 +148,7 @@ func parseInt(key, keytail string, values []string, target reflect.Value) error i, err := strconv.ParseInt(values[0], 10, t.Bits()) if err != nil { - return TypeError{ + return ValueError{ Key: kpath(key, keytail), Type: t, Err: err.(*strconv.NumError).Err, @@ -168,7 +168,7 @@ func parseUint(key, keytail string, values []string, target reflect.Value) error i, err := strconv.ParseUint(values[0], 10, t.Bits()) if err != nil { - return TypeError{ + return ValueError{ Key: kpath(key, keytail), Type: t, Err: err.(*strconv.NumError).Err, @@ -188,7 +188,7 @@ func parseFloat(key, keytail string, values []string, target reflect.Value) erro f, err := strconv.ParseFloat(values[0], t.Bits()) if err != nil { - return TypeError{ + return ValueError{ Key: kpath(key, keytail), Type: t, Err: err.(*strconv.NumError).Err,