From 882b54696ccf92ce003021ad2f39e675d4e7fadb Mon Sep 17 00:00:00 2001 From: violet Date: Wed, 11 Dec 2024 11:17:53 -0500 Subject: [PATCH] fix: return errors from import assertions --- x/distribution/keeper/genesis.go | 2 +- x/gov/genesis.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/distribution/keeper/genesis.go b/x/distribution/keeper/genesis.go index 10ae55e4c37c..75024e2d8e29 100644 --- a/x/distribution/keeper/genesis.go +++ b/x/distribution/keeper/genesis.go @@ -124,7 +124,7 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error balances := k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress()) if balances.IsAllLT(moduleHoldingsInt) { - panic(fmt.Sprintf("distribution module balance is less than module holdings: %s < %s", balances, moduleHoldingsInt)) + return fmt.Errorf("distribution module balance is less than module holdings: %s < %s", balances, moduleHoldingsInt) } return nil } diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 6c2a23be7343..7470f81e6fa3 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -81,7 +81,7 @@ func InitGenesis(ctx context.Context, ak types.AccountKeeper, bk types.BankKeepe // check if the module account can cover the total deposits if !balance.IsAllGTE(totalDeposits) { - panic(fmt.Sprintf("expected module to hold at least %s, but it holds %s", totalDeposits, balance)) + return fmt.Errorf("expected module to hold at least %s, but it holds %s", totalDeposits, balance) } return nil }