• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 13241580467

10 Feb 2025 01:07PM UTC coverage: 57.69% (+8.4%) from 49.311%
13241580467

Pull #9495

github

ziggie1984
graph: fix flake in unit test
Pull Request #9495: fix graphbuilder flake

103558 of 179509 relevant lines covered (57.69%)

24909.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.95
/graph/errors.go
1
package graph
2

3
import "github.com/go-errors/errors"
4

5
var (
6
        // ErrNoFundingTransaction is returned when we are unable to find the
7
        // funding transaction described by the short channel ID on chain.
8
        ErrNoFundingTransaction = errors.New(
9
                "unable to find the funding transaction",
10
        )
11

12
        // ErrInvalidFundingOutput is returned if the channel funding output
13
        // fails validation.
14
        ErrInvalidFundingOutput = errors.New(
15
                "channel funding output validation failed",
16
        )
17

18
        // ErrChannelSpent is returned when we go to validate a channel, but
19
        // the purported funding output has actually already been spent on
20
        // chain.
21
        ErrChannelSpent = errors.New("channel output has been spent")
22
)
23

24
// ErrorCode is used to represent the various errors that can occur within this
25
// package.
26
type ErrorCode uint8
27

28
const (
29
        // ErrOutdated is returned when the routing update already have
30
        // been applied, or a newer update is already known.
31
        ErrOutdated ErrorCode = iota
32

33
        // ErrIgnored is returned when the update have been ignored because
34
        // this update can't bring us something new, or because a node
35
        // announcement was given for node not found in any channel.
36
        ErrIgnored
37
)
38

39
// Error is a structure that represent the error inside the graph package,
40
// this structure carries additional information about error code in order to
41
// be able distinguish errors outside of the current package.
42
type Error struct {
43
        err  *errors.Error
44
        code ErrorCode
45
}
46

47
// Error represents errors as the string
48
// NOTE: Part of the error interface.
49
func (e *Error) Error() string {
×
50
        return e.err.Error()
×
51
}
×
52

53
// A compile time check to ensure Error implements the error interface.
54
var _ error = (*Error)(nil)
55

56
// NewErrf creates a Error by the given error formatted description and
57
// its corresponding error code.
58
func NewErrf(code ErrorCode, format string, a ...interface{}) *Error {
3✔
59
        return &Error{
3✔
60
                code: code,
3✔
61
                err:  errors.Errorf(format, a...),
3✔
62
        }
3✔
63
}
3✔
64

65
// IsError is a helper function which is needed to have ability to check that
66
// returned error has specific error code.
67
func IsError(e interface{}, codes ...ErrorCode) bool {
209✔
68
        err, ok := e.(*Error)
209✔
69
        if !ok {
414✔
70
                return false
205✔
71
        }
205✔
72

73
        for _, code := range codes {
8✔
74
                if err.code == code {
8✔
75
                        return true
4✔
76
                }
4✔
77
        }
78

79
        return false
×
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc