From 4a741df757cf6b1d1b4c0e8c875c34b650f46167 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 23 Jun 2017 10:50:49 +0200 Subject: common/hexutil: wrap errors in json.UnmarshalTypeError This adds type and struct field context to error messages. Instead of "hex string of odd length" users will now see "json: cannot unmarshal hex string of odd length into Go struct field SendTxArgs.from of type common.Address". --- common/types_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'common/types_test.go') diff --git a/common/types_test.go b/common/types_test.go index 9f9d8b767..154c33063 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -21,8 +21,6 @@ import ( "math/big" "strings" "testing" - - "github.com/ethereum/go-ethereum/common/hexutil" ) func TestBytesConversion(t *testing.T) { @@ -43,10 +41,10 @@ func TestHashJsonValidation(t *testing.T) { Size int Error string }{ - {"", 62, hexutil.ErrMissingPrefix.Error()}, - {"0x", 66, "hex string has length 66, want 64 for Hash"}, - {"0x", 63, hexutil.ErrOddLength.Error()}, - {"0x", 0, "hex string has length 0, want 64 for Hash"}, + {"", 62, "json: cannot unmarshal hex string without 0x prefix into Go value of type common.Hash"}, + {"0x", 66, "hex string has length 66, want 64 for common.Hash"}, + {"0x", 63, "json: cannot unmarshal hex string of odd length into Go value of type common.Hash"}, + {"0x", 0, "hex string has length 0, want 64 for common.Hash"}, {"0x", 64, ""}, {"0X", 64, ""}, } -- cgit v1.2.3