]> Sergey Matveev's repositories - btrtrc.git/blob - peer_protocol/ut-holepunch/err-code.go
42b1db1adf3f31d8abbb707918d3de20d92e9c2a
[btrtrc.git] / peer_protocol / ut-holepunch / err-code.go
1 package utHolepunch
2
3 type ErrCode uint32
4
5 var _ error = ErrCode(0)
6
7 const (
8         NoSuchPeer ErrCode = iota + 1
9         NotConnected
10         NoSupport
11         NoSelf
12 )
13
14 func (ec ErrCode) Error() string {
15         switch ec {
16         case NoSuchPeer:
17                 return "target endpoint is invalid"
18         case NotConnected:
19                 return "the relaying peer is not connected to the target peer"
20         case NoSupport:
21                 return "the target peer does not support the holepunch extension"
22         case NoSelf:
23                 return "the target endpoint belongs to the relaying peer"
24         default:
25                 panic(ec)
26         }
27 }