fix: format error should not trigger circuit breaker in sqlx (#3437)

This commit is contained in:
Kevin Wan
2023-07-23 20:40:03 +08:00
committed by GitHub
parent 05db706c62
commit ff04356704
6 changed files with 77 additions and 12 deletions

View File

@@ -103,21 +103,21 @@ func convertTypeFromString(kind reflect.Kind, str string) (any, error) {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
intValue, err := strconv.ParseInt(str, 10, 64)
if err != nil {
return 0, fmt.Errorf("the value %q cannot parsed as int", str)
return 0, fmt.Errorf("the value %q cannot be parsed as int", str)
}
return intValue, nil
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
uintValue, err := strconv.ParseUint(str, 10, 64)
if err != nil {
return 0, fmt.Errorf("the value %q cannot parsed as uint", str)
return 0, fmt.Errorf("the value %q cannot be parsed as uint", str)
}
return uintValue, nil
case reflect.Float32, reflect.Float64:
floatValue, err := strconv.ParseFloat(str, 64)
if err != nil {
return 0, fmt.Errorf("the value %q cannot parsed as float", str)
return 0, fmt.Errorf("the value %q cannot be parsed as float", str)
}
return floatValue, nil