From fe13a533f5a05e4fcd35a632d31c66d4f63d054a Mon Sep 17 00:00:00 2001 From: "qiying.wang" Date: Thu, 2 Mar 2023 01:42:57 -0800 Subject: [PATCH] chore: remove redundant prefix of "error: " in error creation --- core/collection/set.go | 10 +++++----- core/mapping/unmarshaler.go | 2 +- core/stores/sqlx/utils.go | 6 +++--- tools/goctl/model/sql/test/utils.go | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/collection/set.go b/core/collection/set.go index e067ae23..d8d51110 100644 --- a/core/collection/set.go +++ b/core/collection/set.go @@ -213,23 +213,23 @@ func (s *Set) validate(i interface{}) { switch i.(type) { case int: if s.tp != intType { - logx.Errorf("Error: element is int, but set contains elements with type %d", s.tp) + logx.Errorf("element is int, but set contains elements with type %d", s.tp) } case int64: if s.tp != int64Type { - logx.Errorf("Error: element is int64, but set contains elements with type %d", s.tp) + logx.Errorf("element is int64, but set contains elements with type %d", s.tp) } case uint: if s.tp != uintType { - logx.Errorf("Error: element is uint, but set contains elements with type %d", s.tp) + logx.Errorf("element is uint, but set contains elements with type %d", s.tp) } case uint64: if s.tp != uint64Type { - logx.Errorf("Error: element is uint64, but set contains elements with type %d", s.tp) + logx.Errorf("element is uint64, but set contains elements with type %d", s.tp) } case string: if s.tp != stringType { - logx.Errorf("Error: element is string, but set contains elements with type %d", s.tp) + logx.Errorf("element is string, but set contains elements with type %d", s.tp) } } } diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go index dadc6716..b1485c61 100644 --- a/core/mapping/unmarshaler.go +++ b/core/mapping/unmarshaler.go @@ -1009,7 +1009,7 @@ func newInitError(name string) error { } func newTypeMismatchError(name string) error { - return fmt.Errorf("error: type mismatch for field %s", name) + return fmt.Errorf("type mismatch for field %s", name) } func readKeys(key string) []string { diff --git a/core/stores/sqlx/utils.go b/core/stores/sqlx/utils.go index 58428ecc..47517122 100644 --- a/core/stores/sqlx/utils.go +++ b/core/stores/sqlx/utils.go @@ -66,7 +66,7 @@ func format(query string, args ...interface{}) (string, error) { switch ch { case '?': if argIndex >= numArgs { - return "", fmt.Errorf("error: %d ? in sql, but less arguments provided", argIndex) + return "", fmt.Errorf("%d ? in sql, but less arguments provided", argIndex) } writeValue(&b, args[argIndex]) @@ -93,7 +93,7 @@ func format(query string, args ...interface{}) (string, error) { index-- if index < 0 || numArgs <= index { - return "", fmt.Errorf("error: wrong index %d in sql", index) + return "", fmt.Errorf("wrong index %d in sql", index) } writeValue(&b, args[index]) @@ -124,7 +124,7 @@ func format(query string, args ...interface{}) (string, error) { } if argIndex < numArgs { - return "", fmt.Errorf("error: %d arguments provided, not matching sql", argIndex) + return "", fmt.Errorf("%d arguments provided, not matching sql", argIndex) } return b.String(), nil diff --git a/tools/goctl/model/sql/test/utils.go b/tools/goctl/model/sql/test/utils.go index 2491af51..34d4a04f 100644 --- a/tools/goctl/model/sql/test/utils.go +++ b/tools/goctl/model/sql/test/utils.go @@ -53,7 +53,7 @@ func format(query string, args ...interface{}) (string, error) { for _, ch := range query { if ch == '?' { if argIndex >= numArgs { - return "", fmt.Errorf("error: %d ? in sql, but less arguments provided", argIndex) + return "", fmt.Errorf("%d ? in sql, but less arguments provided", argIndex) } arg := args[argIndex] @@ -79,7 +79,7 @@ func format(query string, args ...interface{}) (string, error) { } if argIndex < numArgs { - return "", fmt.Errorf("error: %d ? in sql, but more arguments provided", argIndex) + return "", fmt.Errorf("%d ? in sql, but more arguments provided", argIndex) } return b.String(), nil