Skip to content

Commit 1726011

Browse files
fix: Ensure timestamp conversion errors are surfaced
Explicitly call `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 1726011

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/frequenz/client/electricity_trading/_client.py

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

1039+
start_time_utc = dt_to_pb_timestamp_utc(start_time) if start_time else None
1040+
end_time_utc = dt_to_pb_timestamp_utc(end_time) if end_time else None
1041+
10391042
if (
10401043
public_order_filter not in self._public_orders_streams
10411044
or not self._public_orders_streams[public_order_filter].is_running
@@ -1047,16 +1050,8 @@ def receive_public_order_book(
10471050
lambda: self.stub.ReceivePublicOrderBookStream(
10481051
electricity_trading_pb2.ReceivePublicOrderBookStreamRequest(
10491052
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-
),
1053+
start_time=start_time_utc,
1054+
end_time=end_time_utc,
10601055
),
10611056
metadata=self._metadata,
10621057
),

0 commit comments

Comments
 (0)