Skip to content

Commit 8136ea3

Browse files
fix: Ensure timestamp conversion errors are surfaced
Added a try...except...raise block around the calls to `dt_to_pb_timestamp_utc` for start_time and end_time. Previously, an error during this conversion might not have been handled explicitly at this point. This change guarantees that if the conversion fails, the exception is propagated immediately, improving robustness and aiding debugging by making the failure point clear. Signed-off-by: Matthias Wende <[email protected]>
1 parent 8283f6b commit 8136ea3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/frequenz/client/electricity_trading/_client.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,12 @@ def receive_public_order_book(
10361036
side=side,
10371037
)
10381038

1039+
try:
1040+
start_time_utc = dt_to_pb_timestamp_utc(start_time) if start_time else None
1041+
end_time_utc = dt_to_pb_timestamp_utc(end_time) if end_time else None
1042+
except:
1043+
raise
1044+
10391045
if (
10401046
public_order_filter not in self._public_orders_streams
10411047
or not self._public_orders_streams[public_order_filter].is_running
@@ -1047,16 +1053,8 @@ def receive_public_order_book(
10471053
lambda: self.stub.ReceivePublicOrderBookStream(
10481054
electricity_trading_pb2.ReceivePublicOrderBookStreamRequest(
10491055
filter=public_order_filter.to_pb(),
1050-
start_time=(
1051-
dt_to_pb_timestamp_utc(start_time)
1052-
if start_time
1053-
else None
1054-
),
1055-
end_time=(
1056-
dt_to_pb_timestamp_utc(end_time)
1057-
if end_time
1058-
else None
1059-
),
1056+
start_time=start_time_utc,
1057+
end_time=end_time_utc,
10601058
),
10611059
metadata=self._metadata,
10621060
),

0 commit comments

Comments
 (0)