Skip to content

Commit

Permalink
Modbustk error handler doesn't include .message
Browse files Browse the repository at this point in the history
  • Loading branch information
craig8 committed May 1, 2024
1 parent 3d61241 commit b3e0f3e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,10 @@ def read_request(self, request):
)
self._data.update(request.parse_values(results))
except (AttributeError, ModbusError) as err:
if "Exception code" in err.message:
raise Exception("{0}: {1}".format(err.message,
helpers.TABLE_EXCEPTION_CODE.get(err.message[-1], "UNDEFINED")))
if err is ModbusError:
code = err.get_exception_code()
raise Exception(f'{err.args[0]}, {helpers.TABLE_EXCEPTION_CODE.get(code, "UNDEFINED")}')

logger.warning("modbus read_all() failure on request: %s\tError: %s", request, err)

def read_all(self):
Expand Down

0 comments on commit b3e0f3e

Please sign in to comment.