github.com/aigarnetwork/aigar@v0.0.0-20191115204914-d59a6eb70f8e/p2p/dnsdisc/error.go (about) 1 // Copyright 2018 The go-ethereum Authors 2 // Copyright 2019 The go-aigar Authors 3 // This file is part of the go-aigar library. 4 // 5 // The go-aigar library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-aigar library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-aigar library. If not, see <http://www.gnu.org/licenses/>. 17 18 package dnsdisc 19 20 import ( 21 "errors" 22 "fmt" 23 ) 24 25 // Entry parse errors. 26 var ( 27 errUnknownEntry = errors.New("unknown entry type") 28 errNoPubkey = errors.New("missing public key") 29 errBadPubkey = errors.New("invalid public key") 30 errInvalidENR = errors.New("invalid node record") 31 errInvalidChild = errors.New("invalid child hash") 32 errInvalidSig = errors.New("invalid base64 signature") 33 errSyntax = errors.New("invalid syntax") 34 ) 35 36 // Resolver/sync errors 37 var ( 38 errNoRoot = errors.New("no valid root found") 39 errNoEntry = errors.New("no valid tree entry found") 40 errHashMismatch = errors.New("hash mismatch") 41 errENRInLinkTree = errors.New("enr entry in link tree") 42 errLinkInENRTree = errors.New("link entry in ENR tree") 43 ) 44 45 type nameError struct { 46 name string 47 err error 48 } 49 50 func (err nameError) Error() string { 51 if ee, ok := err.err.(entryError); ok { 52 return fmt.Sprintf("invalid %s entry at %s: %v", ee.typ, err.name, ee.err) 53 } 54 return err.name + ": " + err.err.Error() 55 } 56 57 type entryError struct { 58 typ string 59 err error 60 } 61 62 func (err entryError) Error() string { 63 return fmt.Sprintf("invalid %s entry: %v", err.typ, err.err) 64 }