Skip to content

Commit

Permalink
Make error message verbs/tense consistent (cosmos#1292)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

Closes cosmos#1232

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [x] New and updated code has appropriate documentation
- [x] New and updated code has new and/or updated testing
- [x] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [x] Linked issues closed with keywords


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

**Chores:**
- Updated error messages in `GetNodeKey` function in `node/crypto.go`
for better clarity.
- Enhanced error descriptions in several functions within `node/full.go`
to provide more detailed information.
- Improved error messages in `newLightNode` function in `node/light.go`
to offer more specific information about startup and initialization
errors.

These changes aim to improve the clarity of error messages, aiding in
quicker identification and resolution of issues. No functionality or
logic has been altered.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Manav-Aggarwal authored Oct 30, 2023
1 parent d916f48 commit cc657b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion node/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetNodeKey(nodeKey *p2p.NodeKey) (crypto.PrivKey, error) {
case "ed25519":
privKey, err := crypto.UnmarshalEd25519PrivateKey(nodeKey.PrivKey.Bytes())
if err != nil {
return nil, fmt.Errorf("node private key unmarshaling error: %w", err)
return nil, fmt.Errorf("error while node private key: %w", err)
}
return privKey, nil
default:
Expand Down
12 changes: 6 additions & 6 deletions node/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func initProxyApp(clientCreator proxy.ClientCreator, logger log.Logger) (proxy.A
proxyApp := proxy.NewAppConns(clientCreator, proxy.NopMetrics())
proxyApp.SetLogger(logger.With("module", "proxy"))
if err := proxyApp.Start(); err != nil {
return nil, fmt.Errorf("error starting proxy app connections: %v", err)
return nil, fmt.Errorf("error while starting proxy app connections: %v", err)
}
return proxyApp, nil
}
Expand All @@ -202,11 +202,11 @@ func initBaseKV(nodeConfig config.NodeConfig, logger log.Logger) (ds.TxnDatastor
func initDALC(nodeConfig config.NodeConfig, dalcKV ds.TxnDatastore, logger log.Logger) (da.DataAvailabilityLayerClient, error) {
dalc := registry.GetClient(nodeConfig.DALayer)
if dalc == nil {
return nil, fmt.Errorf("couldn't get data availability client named '%s'", nodeConfig.DALayer)
return nil, fmt.Errorf("errror while getting data availability client named '%s'", nodeConfig.DALayer)
}
err := dalc.Init(nodeConfig.NamespaceID, []byte(nodeConfig.DAConfig), dalcKV, logger.With("module", "da_client"))
if err != nil {
return nil, fmt.Errorf("data availability layer client initialization error: %w", err)
return nil, fmt.Errorf("error while initializing data availability layer client: %w", err)
}
return dalc, nil
}
Expand All @@ -220,23 +220,23 @@ func initMempool(logger log.Logger, proxyApp proxy.AppConns) *mempoolv1.TxMempoo
func initHeaderSyncService(ctx context.Context, mainKV ds.TxnDatastore, nodeConfig config.NodeConfig, genesis *cmtypes.GenesisDoc, p2pClient *p2p.Client, logger log.Logger) (*block.HeaderSynceService, error) {
headerSyncService, err := block.NewHeaderSynceService(ctx, mainKV, nodeConfig, genesis, p2pClient, logger.With("module", "HeaderSyncService"))
if err != nil {
return nil, fmt.Errorf("HeaderSyncService initialization error: %w", err)
return nil, fmt.Errorf("error while initializing HeaderSyncService: %w", err)
}
return headerSyncService, nil
}

func initBlockSyncService(ctx context.Context, mainKV ds.TxnDatastore, nodeConfig config.NodeConfig, genesis *cmtypes.GenesisDoc, p2pClient *p2p.Client, logger log.Logger) (*block.BlockSyncService, error) {
blockSyncService, err := block.NewBlockSyncService(ctx, mainKV, nodeConfig, genesis, p2pClient, logger.With("module", "BlockSyncService"))
if err != nil {
return nil, fmt.Errorf("HeaderSyncService initialization error: %w", err)
return nil, fmt.Errorf("error while initializing HeaderSyncService: %w", err)
}
return blockSyncService, nil
}

func initBlockManager(signingKey crypto.PrivKey, nodeConfig config.NodeConfig, genesis *cmtypes.GenesisDoc, store store.Store, mempool mempool.Mempool, proxyApp proxy.AppConns, dalc da.DataAvailabilityLayerClient, eventBus *cmtypes.EventBus, logger log.Logger, blockSyncService *block.BlockSyncService) (*block.Manager, error) {
blockManager, err := block.NewManager(signingKey, nodeConfig.BlockManagerConfig, genesis, store, mempool, proxyApp.Consensus(), dalc, eventBus, logger.With("module", "BlockManager"), blockSyncService.BlockStore())
if err != nil {
return nil, fmt.Errorf("BlockManager initialization error: %w", err)
return nil, fmt.Errorf("error while initializing BlockManager: %w", err)
}
return blockManager, nil
}
Expand Down
4 changes: 2 additions & 2 deletions node/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func newLightNode(
proxyApp := proxy.NewAppConns(clientCreator, proxy.NopMetrics())
proxyApp.SetLogger(logger.With("module", "proxy"))
if err := proxyApp.Start(); err != nil {
return nil, fmt.Errorf("error starting proxy app connections: %v", err)
return nil, fmt.Errorf("error while starting proxy app connections: %v", err)
}

datastore, err := openDatastore(conf, logger)
Expand All @@ -64,7 +64,7 @@ func newLightNode(

headerSyncService, err := block.NewHeaderSynceService(ctx, datastore, conf, genesis, client, logger.With("module", "HeaderSyncService"))
if err != nil {
return nil, fmt.Errorf("HeaderSyncService initialization error: %w", err)
return nil, fmt.Errorf("error while initializing HeaderSyncService: %w", err)
}

ctx, cancel := context.WithCancel(ctx)
Expand Down

0 comments on commit cc657b0

Please sign in to comment.