From cdfb195a6e9cc9e32451e584b4b79bb954134b4f Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Sat, 2 Nov 2024 00:31:48 +0900 Subject: [PATCH] Update logging and exception handling --- flow_py_sdk/client/entities.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flow_py_sdk/client/entities.py b/flow_py_sdk/client/entities.py index 2112e04..a643e72 100644 --- a/flow_py_sdk/client/entities.py +++ b/flow_py_sdk/client/entities.py @@ -160,12 +160,12 @@ def __init__( logging.error( f"JSON decode error for event {event_index} with payload: {payload[:100]}... Error: {str(e)}" ) - self.value = None + raise except Exception as e: logging.error( f"Unexpected error deserializing payload for event {event_index} with payload: {payload[:100]}... Error: {str(e)}" ) - self.value = None + raise @classmethod def from_proto(cls, proto: entities.Event) -> "Event": @@ -179,7 +179,7 @@ def from_proto(cls, proto: entities.Event) -> "Event": ) except Exception as e: logging.error(f"Failed to deserialize event {proto.event_index}: {str(e)}") - return None # Returning None if deserialization fails + raise class Transaction(object): @@ -312,11 +312,11 @@ def from_proto( for i, event_proto in enumerate(proto.events): try: event = Event.from_proto(event_proto) - if event is not None: - events.append(event) + events.append(event) except Exception as e: logging.error(f"Failed to deserialize event {i}: {e}") - continue + raise + return TransactionResultResponse( id_=id,