multi: use the "errors" package everywhere
Replace all usages of the "github.com/go-errors/errors" and "github.com/pkg/errors" packages with the standard lib's "errors" package. This ensures that error wrapping and `errors.Is` checks will work as expected.
This commit is contained in:
44 files changed
+114
-109
No files matched your search
+9
-11
@@ -2,6 +2,7 @@ package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -9,7 +10,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/batch"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
@@ -875,8 +875,8 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex,
|
||||
// already have.
|
||||
lastUpdate, exists, err := b.cfg.Graph.HasLightningNode(ctx, node)
|
||||
if err != nil {
|
||||
return errors.Errorf("unable to query for the "+
|
||||
"existence of node: %v", err)
|
||||
return fmt.Errorf("unable to query for the "+
|
||||
"existence of node: %w", err)
|
||||
}
|
||||
if !exists {
|
||||
return NewErrf(ErrIgnored, "Ignoring node announcement"+
|
||||
@@ -1004,8 +1004,8 @@ func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
|
||||
}
|
||||
|
||||
if err := b.cfg.Graph.AddLightningNode(ctx, node, op...); err != nil {
|
||||
return errors.Errorf("unable to add node %x to the "+
|
||||
"graph: %v", node.PubKeyBytes, err)
|
||||
return fmt.Errorf("unable to add node %x to the "+
|
||||
"graph: %w", node.PubKeyBytes, err)
|
||||
}
|
||||
|
||||
log.Tracef("Updated vertex data for node=%x", node.PubKeyBytes)
|
||||
@@ -1051,7 +1051,7 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
|
||||
edge.ChannelID,
|
||||
)
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||
return errors.Errorf("unable to check for edge existence: %v",
|
||||
return fmt.Errorf("unable to check for edge existence: %w",
|
||||
err)
|
||||
}
|
||||
if isZombie {
|
||||
@@ -1109,8 +1109,7 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
|
||||
|
||||
err = b.cfg.ChainView.UpdateFilter(filterUpdate, b.bestHeight.Load())
|
||||
if err != nil {
|
||||
return errors.Errorf("unable to update chain "+
|
||||
"view: %v", err)
|
||||
return fmt.Errorf("unable to update chain view: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1152,8 +1151,7 @@ func (b *Builder) updateEdge(ctx context.Context,
|
||||
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
||||
b.cfg.Graph.HasChannelEdge(policy.ChannelID)
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||
return errors.Errorf("unable to check for edge existence: %v",
|
||||
err)
|
||||
return fmt.Errorf("unable to check for edge existence: %w", err)
|
||||
}
|
||||
|
||||
// If the channel is marked as a zombie in our database, and
|
||||
@@ -1212,7 +1210,7 @@ func (b *Builder) updateEdge(ctx context.Context,
|
||||
// Now that we know this isn't a stale update, we'll apply the new edge
|
||||
// policy to the proper directional edge within the channel graph.
|
||||
if err = b.cfg.Graph.UpdateEdgePolicy(ctx, policy, op...); err != nil {
|
||||
err := errors.Errorf("unable to add channel: %v", err)
|
||||
err := fmt.Errorf("unable to add channel: %w", err)
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"math/rand"
|
||||
@@ -19,7 +20,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package graphdb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"net"
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
@@ -412,8 +412,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
|
||||
// being connected.
|
||||
edgeInfo, _, _, err := c.FetchChannelEdgesByID(m.ChannelID)
|
||||
if err != nil {
|
||||
return errors.Errorf("unable fetch channel edge: %v",
|
||||
err)
|
||||
return fmt.Errorf("unable fetch channel edge: %w", err)
|
||||
}
|
||||
|
||||
// If the flag is one, then the advertising node is actually
|
||||
|
||||
+5
-3
@@ -1,6 +1,8 @@
|
||||
package graph
|
||||
|
||||
import "github.com/go-errors/errors"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ErrorCode is used to represent the various errors that can occur within this
|
||||
// package.
|
||||
@@ -21,7 +23,7 @@ const (
|
||||
// this structure carries additional information about error code in order to
|
||||
// be able distinguish errors outside of the current package.
|
||||
type Error struct {
|
||||
err *errors.Error
|
||||
err error
|
||||
code ErrorCode
|
||||
}
|
||||
|
||||
@@ -39,7 +41,7 @@ var _ error = (*Error)(nil)
|
||||
func NewErrf(code ErrorCode, format string, a ...interface{}) *Error {
|
||||
return &Error{
|
||||
code: code,
|
||||
err: errors.Errorf(format, a...),
|
||||
err: fmt.Errorf(format, a...),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user