Tweak error messaging in the onReceive function for sendtext packets

This commit is contained in:
Ian McEwen
2024-12-27 10:04:36 -07:00
parent b8178d513a
commit 6bab385380
2 changed files with 3 additions and 3 deletions

View File

@@ -74,7 +74,7 @@ def onReceive(packet, interface) -> None:
args
and args.sendtext
and packet["to"] == interface.myInfo.my_node_num
and d["portnum"] == portnums_pb2.PortNum.TEXT_MESSAGE_APP
and d.get("portnum", portnums_pb2.PortNum.UNKNOWN_APP) == portnums_pb2.PortNum.TEXT_MESSAGE_APP
):
interface.close() # after running command then exit
@@ -90,7 +90,7 @@ def onReceive(packet, interface) -> None:
interface.sendText(reply)
except Exception as ex:
print(f"Warning: There is no field {ex} in the packet.")
print(f"Warning: Error processing received packet: {ex}.")
def onConnection(interface, topic=pub.AUTO_TOPIC) -> None: # pylint: disable=W0613

View File

@@ -1608,7 +1608,7 @@ def test_main_onReceive_empty(caplog, capsys):
assert re.search(r"in onReceive", caplog.text, re.MULTILINE)
out, err = capsys.readouterr()
assert re.search(
r"Warning: There is no field 'to' in the packet.", out, re.MULTILINE
r"Warning: Error processing received packet: 'to'.", out, re.MULTILINE
)
assert err == ""