switched to using the subclass of InvalidFrame in the messaging module exception handling.

This commit is contained in:
fawce
2012-03-02 13:10:06 -05:00
parent 2aa4af86aa
commit 12be673011
2 changed files with 9 additions and 10 deletions
+5 -5
View File
@@ -222,7 +222,7 @@ class ParallelBuffer(Component):
try:
event = self.unframe(message)
# deserialization error
except zp.InvalidFrame as exc:
except zp.INVALID_DATASOURE_FRAME as exc:
return self.signal_exception(exc)
try:
@@ -230,7 +230,7 @@ class ParallelBuffer(Component):
self.send_next()
# Invalid message
except zp.InvalidFrame as exc:
except zp.INVALID_DATASOURCE_FRAME as exc:
return self.signal_exception(exc)
#
@@ -449,7 +449,7 @@ class BaseTransform(Component):
try:
event = self.unframe(message)
except zp.InvalidFrame as exc:
except zp.INVALID_FEED_FRAME as exc:
return self.signal_exception(exc)
try:
@@ -463,7 +463,7 @@ class BaseTransform(Component):
try:
transform_frame = self.frame(cur_state)
except zp.InvalidFrame as exc:
except zp.INVALID_TRANSFORM_FRAME as exc:
return self.signal_exception(exc)
self.result_socket.send(transform_frame, self.zmq.NOBLOCK)
@@ -554,7 +554,7 @@ class DataSource(Component):
try:
ds_frame = self.frame(event)
except zp.InvalidFrame as exc:
except zp.INVALID_DATASOURCE_FRAME as exc:
return self.signal_exception(exc)
self.data_socket.send(ds_frame)
+4 -5
View File
@@ -61,15 +61,14 @@ def Enum(*options):
_fields_ = [(o, c_ubyte) for o in options]
return cstruct(*range(len(options)))
class InvalidFrame(Exception):
def __init__(self, got):
self.got = got
def FrameExceptionFactory(name):
"""
Exception factory with a closure around the frame class name.
"""
class NamedInvalidFrame(InvalidFrame):
class InvalidFrame(Exception):
def __init__(self, got):
self.got = got
def __str__(self):
return "Invalid {framecls} Frame: {got}".format(
framecls = name,