Skip to content

Commit

Permalink
fix(assets): more descriptive errors in ParseID
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Apr 1, 2024
1 parent 591fbd7 commit 19be516
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions x/assets/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ func ParseJoinedStoreKey(key []byte, number int) (keys []string, err error) {
func ParseID(key string) (string, uint64, error) {
keys := strings.Split(key, "_")
if len(keys) != 2 {
return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("invalid key:%s", key))
return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("invalid length:%s", key))
}
if len(keys[0]) == 0 {
return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("invalid key:%s", key))
return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("empty key:%s", key))
}
var id uint64
var err error
if id, err = hexutil.DecodeUint64(keys[1]); err != nil {
return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("invalid key:%s", key))
return "", 0, errorsmod.Wrap(ErrParseAssetsStateKey, fmt.Sprintf("not a number :%s", key))
}
return keys[0], id, nil
}

0 comments on commit 19be516

Please sign in to comment.