diff --git a/pkg/cosmos/config/config.go b/pkg/cosmos/config/config.go index 163ec676..77d73b1e 100644 --- a/pkg/cosmos/config/config.go +++ b/pkg/cosmos/config/config.go @@ -151,11 +151,12 @@ func (n *Node) ValidateConfig() (err error) { type TOMLConfigs []*TOMLConfig func (cs TOMLConfigs) validateKeys() (err error) { + var errSlice []error // Unique chain IDs chainIDs := config.UniqueStrings{} for i, c := range cs { if chainIDs.IsDupe(c.ChainID) { - err = errors.Join(err, config.NewErrDuplicate(fmt.Sprintf("%d.ChainID", i), *c.ChainID)) + errSlice = append(errSlice, config.NewErrDuplicate(fmt.Sprintf("%d.ChainID", i), *c.ChainID)) } } @@ -164,7 +165,7 @@ func (cs TOMLConfigs) validateKeys() (err error) { for i, c := range cs { for j, n := range c.Nodes { if names.IsDupe(n.Name) { - err = errors.Join(err, config.NewErrDuplicate(fmt.Sprintf("%d.Nodes.%d.Name", i, j), *n.Name)) + errSlice = append(errSlice, config.NewErrDuplicate(fmt.Sprintf("%d.Nodes.%d.Name", i, j), *n.Name)) } } } @@ -175,11 +176,12 @@ func (cs TOMLConfigs) validateKeys() (err error) { for j, n := range c.Nodes { u := (*url.URL)(n.TendermintURL) if urls.IsDupeFmt(u) { - err = errors.Join(err, config.NewErrDuplicate(fmt.Sprintf("%d.Nodes.%d.TendermintURL", i, j), u.String())) + errSlice = append(errSlice, config.NewErrDuplicate(fmt.Sprintf("%d.Nodes.%d.TendermintURL", i, j), u.String())) } } } - return + + return errors.Join(errSlice...) } func (cs TOMLConfigs) ValidateConfig() (err error) { @@ -297,17 +299,18 @@ func setFromChain(c, f *Chain) { } func (c *TOMLConfig) ValidateConfig() (err error) { + var errSlice []error if c.ChainID == nil { - err = errors.Join(err, config.ErrMissing{Name: "ChainID", Msg: "required for all chains"}) + errSlice = append(errSlice, config.ErrMissing{Name: "ChainID", Msg: "required for all chains"}) } else if *c.ChainID == "" { - err = errors.Join(err, config.ErrEmpty{Name: "ChainID", Msg: "required for all chains"}) + errSlice = append(errSlice, config.ErrEmpty{Name: "ChainID", Msg: "required for all chains"}) } if len(c.Nodes) == 0 { - err = errors.Join(err, config.ErrMissing{Name: "Nodes", Msg: "must have at least one node"}) + errSlice = append(errSlice, config.ErrMissing{Name: "Nodes", Msg: "must have at least one node"}) } - return + return errors.Join(errSlice...) } func (c *TOMLConfig) TOMLString() (string, error) {