From ba2196c468ba1630a34783589fc29de12cf0f922 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 8 Apr 2022 11:21:31 +0200 Subject: [PATCH] return errors immediately instead of appending --- modules/apps/29-fee/types/fee.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 1f979c732d8..35e985ac5ad 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -1,8 +1,6 @@ package types import ( - "strings" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -68,19 +66,16 @@ func (f Fee) Total() sdk.Coins { // Validate asserts that each Fee is valid and all three Fees are not empty or zero func (fee Fee) Validate() error { - var errFees []string if !fee.AckFee.IsValid() { - errFees = append(errFees, "ack fee invalid") + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "invalid acknowledgement fee") } + if !fee.RecvFee.IsValid() { - errFees = append(errFees, "recv fee invalid") - } - if !fee.TimeoutFee.IsValid() { - errFees = append(errFees, "timeout fee invalid") + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "invalid receive fee") } - if len(errFees) > 0 { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "contains invalid fees: %s", strings.Join(errFees, " , ")) + if !fee.TimeoutFee.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "invalid timeout fee") } // if all three fee's are zero or empty return an error