Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace github.com/pkg/errors with stdlib errors #775

Merged
merged 6 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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