Skip to content

Commit

Permalink
fix: Use wrapped errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kayano committed Dec 20, 2023
1 parent a7d6930 commit 165f750
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package grpc

import (
"context"
"errors"
"fmt"

base "cosmossdk.io/api/cosmos/base/tendermint/v1beta1"
Expand All @@ -21,6 +22,12 @@ import (

const valConsStr = "valcons"

var errEndpoint = errors.New("grpc endpoint error")

func endpointError(msg string) error {
return fmt.Errorf("%w: %s", errEndpoint, msg)
}

type Client struct {
cfg config.Config
conn *grpc.ClientConn
Expand Down Expand Up @@ -61,7 +68,7 @@ func (c Client) SignigInfos(ctx context.Context) ([]slashing.ValidatorSigningInf
}

if slashRes == nil {
return nil, fmt.Errorf("got empty response from signing infos endpoint")
return nil, endpointError("got empty response from signing infos endpoint")
}

infos = append(infos, slashRes.GetInfo()...)
Expand Down Expand Up @@ -101,7 +108,7 @@ func (c Client) Validators(ctx context.Context) ([]staking.Validator, error) {
}

if stakingRes == nil {
return nil, fmt.Errorf("got empty response from validators endpoint")
return nil, endpointError("got empty response from validators endpoint")
}

for _, val := range stakingRes.GetValidators() {
Expand Down

0 comments on commit 165f750

Please sign in to comment.