forked from libp2p/go-libp2p-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
34 lines (26 loc) · 784 Bytes
/
error.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
package pnet
// ErrNotInPrivateNetwork is an error that should be returned by libp2p when it
// tries to dial with ForcePrivateNetwork set and no PNet Protector
var ErrNotInPrivateNetwork = NewError("private network was not configured but" +
" is enforced by the environment")
// Error is error type for ease of detecting PNet errors
type Error interface {
IsPNetError() bool
}
// NewError creates new Error
func NewError(err string) error {
return pnetErr("privnet: " + err)
}
// IsPNetError checks if given error is PNet Error
func IsPNetError(err error) bool {
v, ok := err.(Error)
return ok && v.IsPNetError()
}
type pnetErr string
var _ Error = (*pnetErr)(nil)
func (p pnetErr) Error() string {
return string(p)
}
func (pnetErr) IsPNetError() bool {
return true
}