diff --git a/cmd/barak/main.go b/cmd/barak/main.go index c5b4d672..d705e32e 100644 --- a/cmd/barak/main.go +++ b/cmd/barak/main.go @@ -151,7 +151,7 @@ func RunProcess(wait bool, label string, execPath string, args []string, input s existing := barak.processes[label] if existing != nil { barak.mtx.Unlock() - return nil, Errorf("Process already exists: %v", label) + return nil, fmt.Errorf("Process already exists: %v", label) } // Otherwise, create one. @@ -173,7 +173,7 @@ func StopProcess(label string, kill bool) (*ResponseStopProcess, error) { barak.mtx.Unlock() if proc == nil { - return nil, Errorf("Process does not exist: %v", label) + return nil, fmt.Errorf("Process does not exist: %v", label) } err := pcm.Stop(proc, kill) diff --git a/cmd/debora/commands.go b/cmd/debora/commands.go index 37a9b41a..50471c7b 100644 --- a/cmd/debora/commands.go +++ b/cmd/debora/commands.go @@ -27,7 +27,7 @@ func GetNonce(remote string) uint64 { response := btypes.ResponseStatus{} _, err = rpc.Call(remote, "status", Arr(), &response) if err != nil { - panic(Fmt("Error fetching nonce from remote %v: %v", remote, err)) + Exit(Fmt("Error fetching nonce from remote %v: %v", remote, err)) } return response.Nonce } diff --git a/common/errors.go b/common/errors.go index 6cfecf4f..a3312e97 100644 --- a/common/errors.go +++ b/common/errors.go @@ -1,14 +1,9 @@ package common import ( - "errors" "fmt" ) -func Errorf(s string, args ...interface{}) error { - return errors.New(fmt.Sprintf(s, args...)) -} - type StackError struct { Err interface{} Stack []byte diff --git a/consensus/pol.go b/consensus/pol.go index 06784d58..598f90a5 100644 --- a/consensus/pol.go +++ b/consensus/pol.go @@ -33,7 +33,7 @@ type POL struct { func (pol *POL) Verify(valSet *sm.ValidatorSet) error { if uint(len(pol.Votes)) != valSet.Size() { - return Errorf("Invalid POL votes count: Expected %v, got %v", + return fmt.Errorf("Invalid POL votes count: Expected %v, got %v", valSet.Size(), len(pol.Votes)) } @@ -61,16 +61,16 @@ func (pol *POL) Verify(valSet *sm.ValidatorSet) error { BlockParts: pol.BlockParts, }) } else if vote.Round > pol.Round { - return Errorf("Invalid commit round %v for POL %v", vote.Round, pol) + return fmt.Errorf("Invalid commit round %v for POL %v", vote.Round, pol) } // Validate if _, seen := seenValidators[string(val.Address)]; seen { - return Errorf("Duplicate validator for vote %v for POL %v", vote, pol) + return fmt.Errorf("Duplicate validator for vote %v for POL %v", vote, pol) } if !val.PubKey.VerifyBytes(voteDoc, vote.Signature) { - return Errorf("Invalid signature for vote %v for POL %v", vote, pol) + return fmt.Errorf("Invalid signature for vote %v for POL %v", vote, pol) } // Tally @@ -81,7 +81,7 @@ func (pol *POL) Verify(valSet *sm.ValidatorSet) error { if talliedVotingPower > valSet.TotalVotingPower()*2/3 { return nil } else { - return Errorf("Invalid POL, insufficient voting power %v, needed %v", + return fmt.Errorf("Invalid POL, insufficient voting power %v, needed %v", talliedVotingPower, (valSet.TotalVotingPower()*2/3 + 1)) } diff --git a/rpc/http_params.go b/rpc/http_params.go index 36dd122a..2d90e88b 100644 --- a/rpc/http_params.go +++ b/rpc/http_params.go @@ -2,11 +2,10 @@ package rpc import ( "encoding/hex" + "fmt" "net/http" "regexp" "strconv" - - . "github.com/tendermint/tendermint/common" ) var ( @@ -44,7 +43,7 @@ func GetParamInt64(r *http.Request, param string) (int64, error) { s := GetParam(r, param) i, err := strconv.ParseInt(s, 10, 64) if err != nil { - return 0, Errorf(param, err.Error()) + return 0, fmt.Errorf(param, err.Error()) } return i, nil } @@ -53,7 +52,7 @@ func GetParamInt32(r *http.Request, param string) (int32, error) { s := GetParam(r, param) i, err := strconv.ParseInt(s, 10, 32) if err != nil { - return 0, Errorf(param, err.Error()) + return 0, fmt.Errorf(param, err.Error()) } return int32(i), nil } @@ -62,7 +61,7 @@ func GetParamUint64(r *http.Request, param string) (uint64, error) { s := GetParam(r, param) i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return 0, Errorf(param, err.Error()) + return 0, fmt.Errorf(param, err.Error()) } return i, nil } @@ -71,7 +70,7 @@ func GetParamUint(r *http.Request, param string) (uint, error) { s := GetParam(r, param) i, err := strconv.ParseUint(s, 10, 64) if err != nil { - return 0, Errorf(param, err.Error()) + return 0, fmt.Errorf(param, err.Error()) } return uint(i), nil } @@ -79,7 +78,7 @@ func GetParamUint(r *http.Request, param string) (uint, error) { func GetParamRegexp(r *http.Request, param string, re *regexp.Regexp) (string, error) { s := GetParam(r, param) if !re.MatchString(s) { - return "", Errorf(param, "Did not match regular expression %v", re.String()) + return "", fmt.Errorf(param, "Did not match regular expression %v", re.String()) } return s, nil } @@ -88,7 +87,7 @@ func GetParamFloat64(r *http.Request, param string) (float64, error) { s := GetParam(r, param) f, err := strconv.ParseFloat(s, 64) if err != nil { - return 0, Errorf(param, err.Error()) + return 0, fmt.Errorf(param, err.Error()) } return f, nil } diff --git a/state/execution.go b/state/execution.go index 3c771f8b..dcfd5555 100644 --- a/state/execution.go +++ b/state/execution.go @@ -3,6 +3,7 @@ package state import ( "bytes" "errors" + "fmt" "github.com/tendermint/tendermint/account" . "github.com/tendermint/tendermint/common" @@ -20,7 +21,7 @@ func ExecBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeade // State.Hash should match block.StateHash stateHash := s.Hash() if !bytes.Equal(stateHash, block.StateHash) { - return Errorf("Invalid state hash. Expected %X, got %X", + return fmt.Errorf("Invalid state hash. Expected %X, got %X", stateHash, block.StateHash) } return nil diff --git a/state/validator_set.go b/state/validator_set.go index 09589a9d..817e5229 100644 --- a/state/validator_set.go +++ b/state/validator_set.go @@ -225,11 +225,11 @@ func (valSet *ValidatorSet) VerifyValidation(hash []byte, parts types.PartSetHea // Validate if _, seen := seenValidators[string(val.Address)]; seen { - return Errorf("Duplicate validator for commit %v for Validation %v", commit, v) + return fmt.Errorf("Duplicate validator for commit %v for Validation %v", commit, v) } if !val.PubKey.VerifyBytes(commitSignBytes, commit.Signature) { - return Errorf("Invalid signature for commit %v for Validation %v", commit, v) + return fmt.Errorf("Invalid signature for commit %v for Validation %v", commit, v) } // Tally @@ -240,7 +240,7 @@ func (valSet *ValidatorSet) VerifyValidation(hash []byte, parts types.PartSetHea if talliedVotingPower > valSet.TotalVotingPower()*2/3 { return nil } else { - return Errorf("insufficient voting power %v, needed %v", + return fmt.Errorf("insufficient voting power %v, needed %v", talliedVotingPower, (valSet.TotalVotingPower()*2/3 + 1)) } }