Skip to content

Commit

Permalink
refactor: Error handling now includes detailed information using fmt.…
Browse files Browse the repository at this point in the history
…Errorf

Signed-off-by: ChengenH <hce19970702@gmail.com>
  • Loading branch information
ChengenH committed Dec 8, 2024
1 parent 8ca8272 commit 8d3a9e0
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 8d3a9e0

Please sign in to comment.