mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
fix protocol error message memoization
This commit is contained in:
parent
a4dc12f12c
commit
d55d6a5c19
1 changed files with 5 additions and 6 deletions
11
eth/error.go
11
eth/error.go
|
|
@ -52,18 +52,17 @@ func ProtocolError(code int, format string, params ...interface{}) (err *protoco
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self protocolError) Error() (message string) {
|
func (self protocolError) Error() (message string) {
|
||||||
message = self.message
|
if len(message) == 0 {
|
||||||
if message == "" {
|
var ok bool
|
||||||
message, ok := errorToString[self.Code]
|
self.message, ok = errorToString[self.Code]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("invalid error code")
|
panic("invalid error code")
|
||||||
}
|
}
|
||||||
if self.format != "" {
|
if self.format != "" {
|
||||||
message += ": " + fmt.Sprintf(self.format, self.params...)
|
self.message += ": " + fmt.Sprintf(self.format, self.params...)
|
||||||
}
|
}
|
||||||
self.message = message
|
|
||||||
}
|
}
|
||||||
return
|
return self.message
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *protocolError) Fatal() bool {
|
func (self *protocolError) Fatal() bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue