modbus_plugin: generate nicer error message, instead of a traceback
authorMario de Sousa <msousa@fe.up.pt>
Thu, 28 May 2020 11:01:42 +0100
changeset 2648 e4ab768170f9
parent 2647 990004083eb8
child 2649 db68cb0e6bdc
modbus_plugin: generate nicer error message, instead of a traceback
modbus/modbus.py
--- a/modbus/modbus.py	Thu May 28 10:54:48 2020 +0100
+++ b/modbus/modbus.py	Thu May 28 11:01:42 2020 +0100
@@ -621,15 +621,13 @@
         for i in range(0, len(IPServer_port_numbers) - 1):
             for j in range(i + 1, len(IPServer_port_numbers)):
                 if IPServer_port_numbers[i][1] == IPServer_port_numbers[j][1]:
-                    self.GetCTRoot().logger.write_warning(
-                        _("Error: Modbus/IP Servers %{a1}.x and %{a2}.x use the same port number {a3}.\n").
-                        format(
-                            a1=_lt_to_str(IPServer_port_numbers[i][0]),
-                            a2=_lt_to_str(IPServer_port_numbers[j][0]),
-                            a3=IPServer_port_numbers[j][1]))
-                    raise Exception
-                    # TODO: return an error code instead of raising an
-                    # exception
+                    error_message = _("Error: Modbus/IP Servers %{a1}.x and %{a2}.x use the same port number {a3}.\n").format(
+                                        a1=_lt_to_str(IPServer_port_numbers[i][0]),
+                                        a2=_lt_to_str(IPServer_port_numbers[j][0]),
+                                        a3=IPServer_port_numbers[j][1])
+                    self.FatalError(error_message)
+                    #self.GetCTRoot().logger.write_warning(error_message)
+                    #raise Exception
 
         # Determine the current location in Beremiz's project configuration
         # tree