File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
3740func isString (input []byte ) bool {
Original file line number Diff line number Diff line change 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'" },
You can’t perform that action at this time.
0 commit comments