From bbd558f509f7abc4409b7d827f56d4a91cd3efee Mon Sep 17 00:00:00 2001 From: Xiangyu Wang Date: Thu, 21 Oct 2021 19:40:35 +0800 Subject: [PATCH] [skip ci]Improve error messages in convension (#10352) Signed-off-by: Xiangyu Wang --- internal/util/typeutil/convension.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/util/typeutil/convension.go b/internal/util/typeutil/convension.go index f5dd1e12c2..88e5fbf483 100644 --- a/internal/util/typeutil/convension.go +++ b/internal/util/typeutil/convension.go @@ -37,7 +37,7 @@ func BytesToFloat32(bytes []byte) float32 { // BytesToInt64 converts a byte slice to uint64. func BytesToInt64(b []byte) (int64, error) { if len(b) != 8 { - return 0, fmt.Errorf("invalid data, must 8 bytes, but %d", len(b)) + return 0, fmt.Errorf("Failed to convert []byte to int64: invalid data, must 8 bytes, but %d", len(b)) } return int64(binary.BigEndian.Uint64(b)), nil @@ -53,7 +53,7 @@ func Int64ToBytes(v int64) []byte { // BytesToUint64 converts a byte slice to uint64. func BytesToUint64(b []byte) (uint64, error) { if len(b) != 8 { - return 0, fmt.Errorf("invalid data, must 8 bytes, but %d", len(b)) + return 0, fmt.Errorf("Failed to convert []byte to uint64: invalid data, must 8 bytes, but %d", len(b)) } return binary.BigEndian.Uint64(b), nil