Skip to content

Commit

Permalink
refactor(x/tx): Error handling now includes detailed information usin…
Browse files Browse the repository at this point in the history
…g fmt.Errorf (#22796)

Signed-off-by: ChengenH <hce19970702@gmail.com>
  • Loading branch information
ChengenH authored Dec 9, 2024
1 parent 8ca8272 commit 7e02d59
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions x/tx/signing/textual/coins.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ func (vr coinsValueRenderer) Format(ctx context.Context, v protoreflect.Value) (
coin := &basev1beta1.Coin{}
err := coerceToMessage(v.Interface().(protoreflect.Message).Interface(), coin)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to coerce message to coin: %w", err)
}

metadata, err := vr.coinMetadataQuerier(ctx, coin.Denom)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to query coin metadata: %w", err)
}

formatted, err := FormatCoins([]*basev1beta1.Coin{coin}, []*bankv1beta1.Metadata{metadata})
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to format coins: %w", err)
}

return []Screen{{Content: formatted}}, nil
Expand All @@ -68,18 +68,18 @@ func (vr coinsValueRenderer) FormatRepeated(ctx context.Context, v protoreflect.
coin := &basev1beta1.Coin{}
err := coerceToMessage(protoCoins.Get(i).Interface().(protoreflect.Message).Interface(), coin)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to coerce message to coin: %w", err)
}
coins[i] = coin
metadatas[i], err = vr.coinMetadataQuerier(ctx, coin.Denom)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to query coin metadata: %w", err)
}
}

formatted, err := FormatCoins(coins, metadatas)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to format coins: %w", err)
}

return []Screen{{Content: formatted}}, nil
Expand Down

0 comments on commit 7e02d59

Please sign in to comment.