Skip to content

Commit

Permalink
fix: error handling and improve code clarity Update cmd_start.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mdqst authored Jan 13, 2025
1 parent cc5cb36 commit b65b727
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions misc/autocounterd/cmd/cmd_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewStartCmd(io commands.IO) *commands.Command {
commands.Metadata{
Name: "start",
ShortUsage: "start [flags]",
ShortHelp: "Runs the linter for the specified packages",
ShortHelp: "Increments the counter in the specified realm at regular intervals",
},
cfg,
func(_ context.Context, args []string) error {
Expand All @@ -68,15 +68,15 @@ func execStart(cfg *startCfg, args []string, io commands.IO) error {

signer, err := gnoclient.SignerFromBip39(cfg.mnemonic, cfg.chainID, "", uint32(0), uint32(0))
if err != nil {
return err
return fmt.Errorf("failed to create signer: %w", err)
}
if err := signer.Validate(); err != nil {
return err
return fmt.Errorf("invalid signer: %w", err)
}

rpcClient, err := rpcclient.NewHTTPClient(cfg.rpcURL)
if err != nil {
return err
return fmt.Errorf("failed to create RPC client: %w", err)
}

client := gnoclient.Client{
Expand All @@ -97,7 +97,7 @@ func execStart(cfg *startCfg, args []string, io commands.IO) error {
})

if err != nil {
fmt.Printf("[ERROR] Failed to call Incr on %s, %+v\n", cfg.realmPath, err.Error())
fmt.Printf("[ERROR] Failed to call Incr on %s: %v\n", cfg.realmPath, err)
} else {
fmt.Println("[INFO] Counter incremented with success")
}
Expand Down

0 comments on commit b65b727

Please sign in to comment.