mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-11 14:03:57 +08:00
switched to using the subclass of InvalidFrame in the messaging module exception handling.
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user