mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-03 14:47:16 +00:00
replace errors.go with github.com/pkg/errors (2/2) (#3890)
* init of (2/2) common errors * Remove instances of cmn.Error (2/2) - Replace usage of cmnError and errorWrap - ref #3862 Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * comment wording * simplify IsErrXXX functions * log panic along with stopping the MConnection
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type errNoData struct{}
|
||||
@@ -12,13 +12,10 @@ func (e errNoData) Error() string {
|
||||
|
||||
// IsErrNoData checks whether an error is due to a query returning empty data
|
||||
func IsErrNoData(err error) bool {
|
||||
if err_, ok := err.(cmn.Error); ok {
|
||||
_, ok := err_.Data().(errNoData)
|
||||
return ok
|
||||
}
|
||||
return false
|
||||
_, ok := errors.Cause(err).(errNoData)
|
||||
return ok
|
||||
}
|
||||
|
||||
func ErrNoData() error {
|
||||
return cmn.ErrorWrap(errNoData{}, "")
|
||||
return errors.Wrap(errNoData{}, "")
|
||||
}
|
||||
|
||||
+4
-3
@@ -4,9 +4,10 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/merkle"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/lite"
|
||||
lerr "github.com/tendermint/tendermint/lite/errors"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
@@ -83,7 +84,7 @@ func GetWithProofOptions(prt *merkle.ProofRuntime, path string, key []byte, opts
|
||||
kp = kp.AppendKey(resp.Key, merkle.KeyEncodingURL)
|
||||
err = prt.VerifyValue(resp.Proof, signedHeader.AppHash, kp.String(), resp.Value)
|
||||
if err != nil {
|
||||
return nil, cmn.ErrorWrap(err, "Couldn't verify value proof")
|
||||
return nil, errors.Wrap(err, "Couldn't verify value proof")
|
||||
}
|
||||
return &ctypes.ResultABCIQuery{Response: resp}, nil
|
||||
} else {
|
||||
@@ -92,7 +93,7 @@ func GetWithProofOptions(prt *merkle.ProofRuntime, path string, key []byte, opts
|
||||
// XXX How do we encode the key into a string...
|
||||
err = prt.VerifyAbsence(resp.Proof, signedHeader.AppHash, string(resp.Key))
|
||||
if err != nil {
|
||||
return nil, cmn.ErrorWrap(err, "Couldn't verify absence proof")
|
||||
return nil, errors.Wrap(err, "Couldn't verify absence proof")
|
||||
}
|
||||
return &ctypes.ResultABCIQuery{Response: resp}, nil
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
log "github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/lite"
|
||||
lclient "github.com/tendermint/tendermint/lite/client"
|
||||
@@ -29,11 +30,11 @@ func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logge
|
||||
logger.Info("lite/proxy/NewVerifier found no trusted full commit, initializing from source from height 1...")
|
||||
fc, err := source.LatestFullCommit(chainID, 1, 1)
|
||||
if err != nil {
|
||||
return nil, cmn.ErrorWrap(err, "fetching source full commit @ height 1")
|
||||
return nil, errors.Wrap(err, "fetching source full commit @ height 1")
|
||||
}
|
||||
err = trust.SaveFullCommit(fc)
|
||||
if err != nil {
|
||||
return nil, cmn.ErrorWrap(err, "saving full commit to trusted")
|
||||
return nil, errors.Wrap(err, "saving full commit to trusted")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user