Skip to content

Commit

Permalink
Replace github.com/pkg/errors with stdlib errors (#775)
Browse files Browse the repository at this point in the history
* Replace github.com/pkg/errors with stdlib errors

* Update CHANGELOG.md

Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
dkmccandless and damiannolan authored Jan 21, 2022
1 parent a6656a0 commit f822756
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Dependencies

* [\#404](https://github.com/cosmos/ibc-go/pull/404) Bump Go version to 1.17
* (core) [\#709](https://github.com/cosmos/ibc-go/pull/709) Replace github.com/pkg/errors with stdlib errors

### API Breaking

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.4.1
Expand Down Expand Up @@ -91,6 +90,7 @@ require (
github.com/opencontainers/runc v1.0.3 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
Expand Down
29 changes: 14 additions & 15 deletions modules/core/02-client/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
Expand Down Expand Up @@ -46,11 +45,11 @@ func NewCreateClientCmd() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(clientContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for client state were provided")
return fmt.Errorf("neither JSON input nor path to .json file for client state were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &clientState); err != nil {
return errors.Wrap(err, "error unmarshalling client state file")
return fmt.Errorf("error unmarshalling client state file: %w", err)
}
}

Expand All @@ -62,11 +61,11 @@ func NewCreateClientCmd() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(consensusContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for consensus state were provided")
return fmt.Errorf("neither JSON input nor path to .json file for consensus state were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &consensusState); err != nil {
return errors.Wrap(err, "error unmarshalling consensus state file")
return fmt.Errorf("error unmarshalling consensus state file: %w", err)
}
}

Expand Down Expand Up @@ -108,11 +107,11 @@ func NewUpdateClientCmd() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(headerContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for header were provided")
return fmt.Errorf("neither JSON input nor path to .json file for header were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &header); err != nil {
return errors.Wrap(err, "error unmarshalling header file")
return fmt.Errorf("error unmarshalling header file: %w", err)
}
}

Expand Down Expand Up @@ -149,11 +148,11 @@ func NewSubmitMisbehaviourCmd() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(misbehaviourContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for misbehaviour were provided")
return fmt.Errorf("neither JSON input nor path to .json file for misbehaviour were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, misbehaviour); err != nil {
return errors.Wrap(err, "error unmarshalling misbehaviour file")
return fmt.Errorf("error unmarshalling misbehaviour file: %w", err)
}
}

Expand Down Expand Up @@ -193,11 +192,11 @@ func NewUpgradeClientCmd() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(clientContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for client state were provided")
return fmt.Errorf("neither JSON input nor path to .json file for client state were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &clientState); err != nil {
return errors.Wrap(err, "error unmarshalling client state file")
return fmt.Errorf("error unmarshalling client state file: %w", err)
}
}

Expand All @@ -209,11 +208,11 @@ func NewUpgradeClientCmd() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(consensusContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for consensus state were provided")
return fmt.Errorf("neither JSON input nor path to .json file for consensus state were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &consensusState); err != nil {
return errors.Wrap(err, "error unmarshalling consensus state file")
return fmt.Errorf("error unmarshalling consensus state file: %w", err)
}
}

Expand Down Expand Up @@ -350,11 +349,11 @@ func NewCmdSubmitUpgradeProposal() *cobra.Command {
// check for file path if JSON input is not provided
contents, err := ioutil.ReadFile(clientContentOrFileName)
if err != nil {
return errors.Wrap(err, "neither JSON input nor path to .json file for client state were provided")
return fmt.Errorf("neither JSON input nor path to .json file for client state were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &clientState); err != nil {
return errors.Wrap(err, "error unmarshalling client state file")
return fmt.Errorf("error unmarshalling client state file: %w", err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions modules/core/03-connection/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package utils

import (
"context"
"errors"
"fmt"
"io/ioutil"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/pkg/errors"

clientutils "github.com/cosmos/ibc-go/v3/modules/core/02-client/client/utils"
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
Expand Down Expand Up @@ -176,7 +176,7 @@ func ParseClientState(cdc *codec.LegacyAmino, arg string) (exported.ClientState,
return nil, errors.New("either JSON input nor path to .json file were provided")
}
if err := cdc.UnmarshalJSON(contents, &clientState); err != nil {
return nil, errors.Wrap(err, "error unmarshalling client state")
return nil, fmt.Errorf("error unmarshalling client state: %w", err)
}
}
return clientState, nil
Expand All @@ -193,7 +193,7 @@ func ParsePrefix(cdc *codec.LegacyAmino, arg string) (commitmenttypes.MerklePref
return commitmenttypes.MerklePrefix{}, errors.New("neither JSON input nor path to .json file were provided")
}
if err := cdc.UnmarshalJSON(contents, &prefix); err != nil {
return commitmenttypes.MerklePrefix{}, errors.Wrap(err, "error unmarshalling commitment prefix")
return commitmenttypes.MerklePrefix{}, fmt.Errorf("error unmarshalling commitment prefix: %w", err)
}
}
return prefix, nil
Expand Down

0 comments on commit f822756

Please sign in to comment.