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

lightningnetwork / lnd / 14358372723

09 Apr 2025 01:26PM UTC coverage: 56.696% (-12.3%) from 69.037%
14358372723

Pull #9696

github

web-flow
Merge e2837e400 into 867d27d68
Pull Request #9696: Add `development_guidelines.md` for both human and machine

107055 of 188823 relevant lines covered (56.7%)

22721.56 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
// ErrorCode is used to represent the various errors that can occur within this
6
// package.
7
type ErrorCode uint8
8

9
const (
10
        // ErrOutdated is returned when the routing update already have
11
        // been applied, or a newer update is already known.
12
        ErrOutdated ErrorCode = iota
13

14
        // ErrIgnored is returned when the update have been ignored because
15
        // this update can't bring us something new, or because a node
16
        // announcement was given for node not found in any channel.
17
        ErrIgnored
18
)
19

20
// Error is a structure that represent the error inside the graph package,
21
// this structure carries additional information about error code in order to
22
// be able distinguish errors outside of the current package.
23
type Error struct {
24
        err  *errors.Error
25
        code ErrorCode
26
}
27

28
// Error represents errors as the string
29
// NOTE: Part of the error interface.
30
func (e *Error) Error() string {
×
31
        return e.err.Error()
×
32
}
×
33

34
// A compile time check to ensure Error implements the error interface.
35
var _ error = (*Error)(nil)
36

37
// NewErrf creates a Error by the given error formatted description and
38
// its corresponding error code.
39
func NewErrf(code ErrorCode, format string, a ...interface{}) *Error {
3✔
40
        return &Error{
3✔
41
                code: code,
3✔
42
                err:  errors.Errorf(format, a...),
3✔
43
        }
3✔
44
}
3✔
45

46
// IsError is a helper function which is needed to have ability to check that
47
// returned error has specific error code.
48
func IsError(e interface{}, codes ...ErrorCode) bool {
5✔
49
        err, ok := e.(*Error)
5✔
50
        if !ok {
6✔
51
                return false
1✔
52
        }
1✔
53

54
        for _, code := range codes {
8✔
55
                if err.code == code {
8✔
56
                        return true
4✔
57
                }
4✔
58
        }
59

60
        return false
×
61
}
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