mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 15:04:22 +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:
@@ -2,7 +2,8 @@ package conn
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"runtime/debug"
|
||||
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@@ -12,6 +13,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
flow "github.com/tendermint/tendermint/libs/flowrate"
|
||||
@@ -313,8 +316,8 @@ func (c *MConnection) flush() {
|
||||
// Catch panics, usually caused by remote disconnects.
|
||||
func (c *MConnection) _recover() {
|
||||
if r := recover(); r != nil {
|
||||
err := cmn.ErrorWrap(r, "recovered panic in MConnection")
|
||||
c.stopForError(err)
|
||||
c.Logger.Error("MConnection panicked", "err", r, "stack", string(debug.Stack()))
|
||||
c.stopForError(errors.Errorf("recovered from panic: %v", r))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -113,13 +114,13 @@ func testOutboundPeerConn(
|
||||
var pc peerConn
|
||||
conn, err := testDial(addr, config)
|
||||
if err != nil {
|
||||
return pc, cmn.ErrorWrap(err, "Error creating peer")
|
||||
return pc, errors.Wrap(err, "Error creating peer")
|
||||
}
|
||||
|
||||
pc, err = testPeerConn(conn, config, true, persistent, ourNodePrivKey, addr)
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
return pc, cmn.ErrorWrap(err, cerr.Error())
|
||||
return pc, errors.Wrap(err, cerr.Error())
|
||||
}
|
||||
return pc, err
|
||||
}
|
||||
@@ -127,7 +128,7 @@ func testOutboundPeerConn(
|
||||
// ensure dialed ID matches connection ID
|
||||
if addr.ID != pc.ID() {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
return pc, cmn.ErrorWrap(err, cerr.Error())
|
||||
return pc, errors.Wrap(err, cerr.Error())
|
||||
}
|
||||
return pc, ErrSwitchAuthenticationFailure{addr, pc.ID()}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user