Skip to content

Commit e0e2064

Browse files
author
Alan Christie
committed
test: More message debug
1 parent 6c537a0 commit e0e2064

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/app.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,19 +452,29 @@ async def on_message_for_websocket(
452452
message_string = str(msg)[2:-1]
453453
_LOGGER.info("TRIMMED %s", message_context.offset)
454454
if message_string[0] != "{":
455-
_LOGGER.info("IS JSON %s", message_context.offset)
455+
_LOGGER.info("IS PROTOBUF %s", message_context.offset)
456456
# The EventStream Service is permitted to append to the protobuf string
457457
# as long as it uses the '|' delimiter. Here qwe add offset and timestamp.
458458
message_string += f"|ordinal: {message_context.offset}"
459459
message_string += f"|timestamp: {message_context.timestamp}"
460460
else:
461-
_LOGGER.info("IS PROTOBUF %s", message_context.offset)
461+
_LOGGER.info("IS JSON %s", message_context.offset)
462462
# The EventStream Service is permitted to append to the JSON string
463463
# as long as it uses keys with the prefix "ess_"
464-
msg_dict: dict[str, Any] = json.loads(message_string)
464+
try:
465+
msg_dict: dict[str, Any] = json.loads(message_string)
466+
except Exception as ex: # pylint: disable=broad-exception-caught
467+
_LOGGER.info(
468+
"LOADS() EXCEPTION %s (%s)", message_context.offset, ex
469+
)
465470
msg_dict["ess_ordinal"] = message_context.offset
466471
msg_dict["ess_timestamp"] = message_context.timestamp
467-
message_string = json.dumps(msg_dict)
472+
try:
473+
message_string = json.dumps(msg_dict)
474+
except Exception as ex: # pylint: disable=broad-exception-caught
475+
_LOGGER.info(
476+
"DUMPS() EXCEPTION %s (%s)", message_context.offset, ex
477+
)
468478
try:
469479
# Pass on and count
470480
_LOGGER.info("SENDING %s", message_context.offset)

0 commit comments

Comments
 (0)