Skip to content

Commit

Permalink
make errors more informative
Browse files Browse the repository at this point in the history
Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Apr 24, 2024
1 parent 16a9937 commit aa347c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/relay/ethereum/error_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ func CreateErrorRepository(abiPaths []string) (ErrorRepository, error) {
for _, dir := range abiPaths {
if err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
return fmt.Errorf("error encountered during the file tree walk: err=%v, path=%s", err, path)
}
if !info.IsDir() && strings.HasSuffix(info.Name(), ".json") {
f, err := os.Open(path)
if err != nil {
return err
return fmt.Errorf("failed to open a file: err=%v, path=%s", err, path)
}
defer f.Close()

contractABI, err := abi.JSON(f)
if err != nil {
return err
return fmt.Errorf("failed to parse a ABI JSON file: err=%v, path=%s", err, path)
}

for _, errABI := range contractABI.Errors {
Expand All @@ -38,7 +38,7 @@ func CreateErrorRepository(abiPaths []string) (ErrorRepository, error) {
}
return nil
}); err != nil {
return nil, err
return nil, fmt.Errorf("failed to read ABIs from a directory: err=%v, dirpath=%s", err, dir)
}
}

Expand Down

0 comments on commit aa347c2

Please sign in to comment.