diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-10 08:22:38 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-10 08:22:38 +0800 |
commit | 0db4a0e898d09ffa7b6b1289e9a334edc0001cfa (patch) | |
tree | a0b5c8381ab482550ef4800a06d4db086d76a983 /eth/error.go | |
parent | 94e543bc398efbb5c712b6e4cb48d8a57eb3400d (diff) | |
parent | 0d64163fea3a266ceb71cb4c4ee5682052c9ca6c (diff) | |
download | dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.gz dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.bz2 dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.lz dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.xz dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.zst dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.zip |
Merge branch 'poc-9' into develop
Diffstat (limited to 'eth/error.go')
-rw-r--r-- | eth/error.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/eth/error.go b/eth/error.go deleted file mode 100644 index 9c4a68481..000000000 --- a/eth/error.go +++ /dev/null @@ -1,72 +0,0 @@ -package eth - -import ( - "fmt" -) - -const ( - ErrMsgTooLarge = iota - ErrDecode - ErrInvalidMsgCode - ErrProtocolVersionMismatch - ErrNetworkIdMismatch - ErrGenesisBlockMismatch - ErrNoStatusMsg - ErrExtraStatusMsg - ErrInvalidBlock - ErrInvalidPoW - ErrUnrequestedBlock - ErrInsufficientChainInfo -) - -var errorToString = map[int]string{ - ErrMsgTooLarge: "Message too long", - ErrDecode: "Invalid message", - ErrInvalidMsgCode: "Invalid message code", - ErrProtocolVersionMismatch: "Protocol version mismatch", - ErrNetworkIdMismatch: "NetworkId mismatch", - ErrGenesisBlockMismatch: "Genesis block mismatch", - ErrNoStatusMsg: "No status message", - ErrExtraStatusMsg: "Extra status message", - ErrInvalidBlock: "Invalid block", - ErrInvalidPoW: "Invalid PoW", - ErrUnrequestedBlock: "Unrequested block", - ErrInsufficientChainInfo: "Insufficient chain info", -} - -type protocolError struct { - Code int - fatal bool - message string - format string - params []interface{} - // size int -} - -func newProtocolError(code int, format string, params ...interface{}) *protocolError { - return &protocolError{Code: code, format: format, params: params} -} - -func ProtocolError(code int, format string, params ...interface{}) (err *protocolError) { - err = newProtocolError(code, format, params...) - // report(err) - return -} - -func (self protocolError) Error() (message string) { - if len(message) == 0 { - var ok bool - self.message, ok = errorToString[self.Code] - if !ok { - panic("invalid error code") - } - if self.format != "" { - self.message += ": " + fmt.Sprintf(self.format, self.params...) - } - } - return self.message -} - -func (self *protocolError) Fatal() bool { - return self.fatal -} |