forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
83 lines (65 loc) · 1.89 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package p2p
import (
"fmt"
"net"
na "github.com/cometbft/cometbft/p2p/netaddr"
"github.com/cometbft/cometbft/p2p/nodekey"
)
// ErrSwitchDuplicatePeerID to be raised when a peer is connecting with a known
// ID.
type ErrSwitchDuplicatePeerID struct {
ID nodekey.ID
}
func (e ErrSwitchDuplicatePeerID) Error() string {
return fmt.Sprintf("duplicate peer ID %v", e.ID)
}
// ErrSwitchDuplicatePeerIP to be raised whena a peer is connecting with a known
// IP.
type ErrSwitchDuplicatePeerIP struct {
IP net.IP
}
func (e ErrSwitchDuplicatePeerIP) Error() string {
return fmt.Sprintf("duplicate peer IP %v", e.IP.String())
}
// ErrSwitchConnectToSelf to be raised when trying to connect to itself.
type ErrSwitchConnectToSelf struct {
Addr *na.NetAddr
}
func (e ErrSwitchConnectToSelf) Error() string {
return fmt.Sprintf("connect to self: %v", e.Addr)
}
type ErrSwitchAuthenticationFailure struct {
Dialed *na.NetAddr
Got nodekey.ID
}
func (e ErrSwitchAuthenticationFailure) Error() string {
return fmt.Sprintf(
"failed to authenticate peer. Dialed %v, but got peer with ID %s",
e.Dialed,
e.Got,
)
}
// ErrPeerRemoval is raised when attempting to remove a peer results in an error.
type ErrPeerRemoval struct{}
func (ErrPeerRemoval) Error() string {
return "peer removal failed"
}
// -------------------------------------------------------------------
// ErrCurrentlyDialingOrExistingAddress indicates that we're currently
// dialing this address or it belongs to an existing peer.
type ErrCurrentlyDialingOrExistingAddress struct {
Addr string
}
func (e ErrCurrentlyDialingOrExistingAddress) Error() string {
return fmt.Sprintf("connection with %s has been established or dialed", e.Addr)
}
type ErrStart struct {
Service any
Err error
}
func (e ErrStart) Error() string {
return fmt.Sprintf("failed to start %v: %v", e.Service, e.Err)
}
func (e ErrStart) Unwrap() error {
return e.Err
}