Skip to content

Commit

Permalink
accounts/abi: context info on unpack-errors (ethereum#28529)
Browse files Browse the repository at this point in the history
adds contextual information to errors returned by unpack
  • Loading branch information
levisyin authored and Dergarcon committed Jan 31, 2024
1 parent 690cfea commit 4ea2232
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions accounts/abi/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package abi

import (
"bytes"
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -84,10 +83,10 @@ func (e Error) String() string {

func (e *Error) Unpack(data []byte) (interface{}, error) {
if len(data) < 4 {
return "", errors.New("invalid data for unpacking")
return "", fmt.Errorf("insufficient data for unpacking: have %d, want at least 4", len(data))
}
if !bytes.Equal(data[:4], e.ID[:4]) {
return "", errors.New("invalid data for unpacking")
return "", fmt.Errorf("invalid identifier, have %#x want %#x", data[:4], e.ID[:4])
}
return e.Inputs.Unpack(data[4:])
}

0 comments on commit 4ea2232

Please sign in to comment.