diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2018-11-27 08:15:22 -0800 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2018-11-29 19:18:07 +0000 |
commit | 6ccc6e91648312cc210e9b6a18e469e64f4a523f (patch) | |
tree | c80d92e7d8c1c28f90cb92d4455c39c52f3b2617 /src/vpp-api/python/vpp_papi/vpp_transport_socket.py | |
parent | 039a1c2f1401ebf3b38fa9bd55dffff0713b8b98 (diff) |
vpp_papi: Add custom exceptions.
This patchset adds and raises the following custom exception classes:
* class VPPApiError(Exception):
* class VPPNotImplementedError(NotImplementedError):
* class VPPIOError(IOError):
* class VPPRuntimeError(RuntimeError):
* class VPPValueError(ValueError):
* class VPPSerializerValueError(ValueError):
* class VPPStatsIOError(IOError):
* class VPPStatsClientLoadError(RuntimeError):
* class VppTransportShmemIOError(IOError):
* class VppTransportSocketIOError(IOError)
Change-Id: Ia40900fd2dcef148d01125d6c691329fc666901e
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_transport_socket.py')
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_transport_socket.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py index 49e565980f2..393e2e9c9c1 100644 --- a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py +++ b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py @@ -13,7 +13,13 @@ except ImportError: import logging +class VppTransportSocketIOError(IOError): + pass + + class VppTransport(object): + VppTransportSocketIOError = VppTransportSocketIOError + def __init__(self, parent, read_timeout, server_address): self.connected = False self.read_timeout = read_timeout if read_timeout > 0 else 1 @@ -59,7 +65,8 @@ class VppTransport(object): else: self.parent.msg_handler_async(msg) else: - raise IOError(2, 'Unknown response from select') + raise VppTransportSocketIOError( + 2, 'Unknown response from select') def connect(self, name, pfx, msg_handler, rx_qlen): @@ -87,7 +94,7 @@ class VppTransport(object): msg = self._read() hdr, length = self.parent.header.unpack(msg, 0) if hdr.msgid != 16: - raise IOError('Invalid reply message') + raise VppTransportSocketIOError('Invalid reply message') r, length = sockclnt_create_reply.unpack(msg) self.socket_index = r.index @@ -136,7 +143,7 @@ class VppTransport(object): def write(self, buf): """Send a binary-packed message to VPP.""" if not self.connected: - raise IOError(1, 'Not connected') + raise VppTransportSocketIOError(1, 'Not connected') # Send header header = self.header.pack(0, len(buf), 0) @@ -177,7 +184,7 @@ class VppTransport(object): def read(self): if not self.connected: - raise IOError(1, 'Not connected') + raise VppTransportSocketIOError(1, 'Not connected') try: return self.q.get(True, self.read_timeout) except queue.Empty: |