From 00537d17dcab60ca8e87d4eda2f09614e9d49059 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Thu, 20 Oct 2016 16:27:42 -0400 Subject: [PATCH] pass errors upstream --- modpypes/app.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modpypes/app.py b/modpypes/app.py index 4a21849..bb55e0d 100644 --- a/modpypes/app.py +++ b/modpypes/app.py @@ -114,6 +114,11 @@ class ModbusClient(Client, Server): """Got a response from the server.""" if _debug: ModbusClient._debug("confirmation %r", pdu) + # pass through errors + if isinstance(pdu, Exception): + self.response(pdu) + return + # generic decode mpdu = MPDU() mpdu.decode(pdu) @@ -158,6 +163,11 @@ class ModbusServer(Client, Server): """This is a request from a client.""" if _debug: ModbusServer._debug("confirmation %r", pdu) + # pass through errors + if isinstance(pdu, Exception): + self.response(pdu) + return + # generic decoding mpdu = MPDU() mpdu.decode(pdu)