Skip to content

Commit b8e84cf

Browse files
committed
Minor.
1 parent 44e664e commit b8e84cf

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

pkg/utils/hex/plainhex.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ func (b *PlainHexBytes) UnmarshalJSON(input []byte) (err error) {
3131
return &json.UnmarshalTypeError{Value: "non-string", Type: reflect.TypeOf((PlainHexBytes)(nil))}
3232
}
3333
err = b.UnmarshalText(input[1 : len(input)-1])
34-
return fmt.Errorf("UnmarshalJSON failed: %w", err)
34+
if err != nil {
35+
err = fmt.Errorf("UnmarshalJSON failed: %w", err)
36+
}
37+
return err
3538
}
3639

3740
func isString(input []byte) bool {

pkg/utils/hex/plainhex_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var (
2424
unmarshalBytesTests = []unmarshalTest{
2525
// invalid encoding
2626
{input: "", wantErr: "unexpected end of JSON input"},
27-
{input: "null", wantErr: "json: cannot unmarshal non-string into Go value of type utils.PlainHexBytes"},
27+
{input: "null", wantErr: "json: cannot unmarshal non-string into Go value of type hex.PlainHexBytes"},
2828
{input: `"null"`, wantErr: "UnmarshalJSON failed: UnmarshalText failed: encoding/hex: invalid byte: U+006E 'n'"},
2929
{input: `"0x"`, wantErr: "UnmarshalJSON failed: UnmarshalText failed: encoding/hex: invalid byte: U+0078 'x'"},
3030
{input: `"0X"`, wantErr: "UnmarshalJSON failed: UnmarshalText failed: encoding/hex: invalid byte: U+0058 'X'"},

0 commit comments

Comments
 (0)