Protocol error handler fixes
- was broken if there was no error message in "raise" - added default texts for network exceptions
This commit is contained in:
parent
02490e3286
commit
e9b1aa48a9
|
@ -8,23 +8,28 @@ from network.dandelion import Dandelion
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
|
|
||||||
class BMObjectInsufficientPOWError(Exception): pass
|
class BMObjectInsufficientPOWError(Exception):
|
||||||
|
errorCodes = ("Insufficient proof of work")
|
||||||
|
|
||||||
|
|
||||||
class BMObjectInvalidDataError(Exception): pass
|
class BMObjectInvalidDataError(Exception):
|
||||||
|
errorCodes = ("Data invalid")
|
||||||
|
|
||||||
|
|
||||||
class BMObjectExpiredError(Exception): pass
|
class BMObjectExpiredError(Exception):
|
||||||
|
errorCodes = ("Object expired")
|
||||||
|
|
||||||
|
|
||||||
class BMObjectUnwantedStreamError(Exception): pass
|
class BMObjectUnwantedStreamError(Exception):
|
||||||
|
errorCodes = ("Object in unwanted stream")
|
||||||
|
|
||||||
|
|
||||||
class BMObjectInvalidError(Exception): pass
|
class BMObjectInvalidError(Exception):
|
||||||
|
errorCodes = ("Invalid object")
|
||||||
|
|
||||||
|
|
||||||
class BMObjectAlreadyHaveError(Exception):
|
class BMObjectAlreadyHaveError(Exception):
|
||||||
pass
|
errorCodes = ("Already have this object")
|
||||||
|
|
||||||
|
|
||||||
class BMObject(object):
|
class BMObject(object):
|
||||||
|
|
|
@ -24,13 +24,16 @@ import shared
|
||||||
import state
|
import state
|
||||||
import protocol
|
import protocol
|
||||||
|
|
||||||
class BMProtoError(ProxyError): pass
|
class BMProtoError(ProxyError):
|
||||||
|
errorCodes = ("Protocol error")
|
||||||
|
|
||||||
|
|
||||||
class BMProtoInsufficientDataError(BMProtoError): pass
|
class BMProtoInsufficientDataError(BMProtoError):
|
||||||
|
errorCodes = ("Insufficient data")
|
||||||
|
|
||||||
|
|
||||||
class BMProtoExcessiveDataError(BMProtoError): pass
|
class BMProtoExcessiveDataError(BMProtoError):
|
||||||
|
errorCodes = ("Too much data")
|
||||||
|
|
||||||
|
|
||||||
class BMProto(AdvancedDispatcher, ObjectTracker):
|
class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
|
|
|
@ -10,7 +10,7 @@ import state
|
||||||
class ProxyError(Exception):
|
class ProxyError(Exception):
|
||||||
errorCodes = ("UnknownError")
|
errorCodes = ("UnknownError")
|
||||||
|
|
||||||
def __init__(self, code):
|
def __init__(self, code=-1):
|
||||||
self.code = code
|
self.code = code
|
||||||
try:
|
try:
|
||||||
self.message = self.__class__.errorCodes[self.code]
|
self.message = self.__class__.errorCodes[self.code]
|
||||||
|
|
Reference in New Issue
Block a user