github.com/annchain/OG@v0.0.9/p2p/enr/err.go (about) 1 package enr 2 3 import "fmt" 4 5 // KeyError is an error related to a key. 6 type KeyError struct { 7 Key string 8 Err error 9 } 10 11 // Error implements error. 12 func (err *KeyError) Error() string { 13 if err.Err == errNotFound { 14 return fmt.Sprintf("missing ENR key %q", err.Key) 15 } 16 return fmt.Sprintf("ENR key %q: %v", err.Key, err.Err) 17 } 18 19 // IsNotFound reports whether the given error means that a key/value pair is 20 // missing from a record. 21 func IsNotFound(err error) bool { 22 kerr, ok := err.(*KeyError) 23 return ok && kerr.Err == errNotFound 24 }