mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
refactor: unify the error handling methods that are different from the project style
Signed-off-by: LesCyber <andi4cing@gmail.com>
This commit is contained in:
parent
6afcda712a
commit
adf7fb2131
6 changed files with 12 additions and 9 deletions
|
@ -3,6 +3,7 @@ package funding
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
@ -1112,7 +1113,7 @@ func (f *Manager) advanceFundingState(channel *channeldb.OpenChannel,
|
|||
channelState, shortChanID, err := f.getChannelOpeningState(
|
||||
&channel.FundingOutpoint,
|
||||
)
|
||||
if err == channeldb.ErrChannelNotFound {
|
||||
if errors.Is(err, channeldb.ErrChannelNotFound) {
|
||||
// Channel not in fundingManager's opening database,
|
||||
// meaning it was successfully announced to the
|
||||
// network.
|
||||
|
@ -1326,7 +1327,7 @@ func (f *Manager) advancePendingChannelState(channel *channeldb.OpenChannel,
|
|||
}
|
||||
|
||||
confChannel, err := f.waitForFundingWithTimeout(channel)
|
||||
if err == ErrConfirmationTimeout {
|
||||
if errors.Is(err, ErrConfirmationTimeout) {
|
||||
return f.fundingTimeout(channel, pendingChanID)
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("error waiting for funding "+
|
||||
|
|
|
@ -1076,7 +1076,7 @@ func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo,
|
|||
|
||||
// Silence ErrEdgeAlreadyExist so that the batch can
|
||||
// succeed, but propagate the error via local state.
|
||||
if err == ErrEdgeAlreadyExist {
|
||||
if errors.Is(err, ErrEdgeAlreadyExist) {
|
||||
alreadyExists = true
|
||||
return nil
|
||||
}
|
||||
|
@ -3493,7 +3493,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (
|
|||
policy1 = nil
|
||||
policy2 = nil
|
||||
})
|
||||
if err == ErrZombieEdge {
|
||||
if errors.Is(err, ErrZombieEdge) {
|
||||
return edgeInfo, nil, nil, err
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -5,6 +5,7 @@ package lnrpc
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
|
@ -500,7 +501,7 @@ func IsClosedConnError(err error) bool {
|
|||
if err == nil {
|
||||
return false
|
||||
}
|
||||
if err == http.ErrServerClosed {
|
||||
if errors.Is(err, http.ErrServerClosed) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -4001,7 +4001,7 @@ func (p *Brontide) handleCloseMsg(msg *closeMsg) {
|
|||
chanCloser, err := p.fetchActiveChanCloser(msg.cid)
|
||||
if err != nil {
|
||||
// If the channel is not known to us, we'll simply ignore this message.
|
||||
if err == ErrChannelNotFound {
|
||||
if errors.Is(err, ErrChannelNotFound) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1440,7 +1440,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
|||
// If sending everything to this address would invalidate our
|
||||
// reserved wallet balance, we create a new sweep tx, where
|
||||
// we'll send the reserved value back to our wallet.
|
||||
if err == lnwallet.ErrReservedValueInvalidated {
|
||||
if errors.Is(err, lnwallet.ErrReservedValueInvalidated) {
|
||||
sweepTxPkg.CancelSweepAttempt()
|
||||
|
||||
rpcsLog.Debugf("Reserved value %v not satisfied after "+
|
||||
|
@ -4348,7 +4348,7 @@ func (r *rpcServer) nurseryPopulateForceCloseResp(chanPoint *wire.OutPoint,
|
|||
// didn't have any time-locked outputs, then the nursery may not know of
|
||||
// the contract.
|
||||
nurseryInfo, err := r.server.utxoNursery.NurseryReport(chanPoint)
|
||||
if err == contractcourt.ErrContractNotFound {
|
||||
if errors.Is(err, contractcourt.ErrContractNotFound) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
prand "math/rand"
|
||||
|
@ -4906,7 +4907,7 @@ func (s *server) DisconnectPeer(pubKey *btcec.PublicKey) error {
|
|||
// exit in an error as we can't disconnect from a peer that we're not
|
||||
// currently connected to.
|
||||
peer, err := s.findPeerByPubStr(pubStr)
|
||||
if err == ErrPeerNotConnected {
|
||||
if errors.Is(err, ErrPeerNotConnected) {
|
||||
return fmt.Errorf("peer %x is not connected", pubBytes)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue