Skip to content

Commit 89ff2bf

Browse files
committed
ADD: Support chained ErrorMsg in Python client
1 parent 8b4e384 commit 89ff2bf

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.32.0 - TBD
44

55
#### Enhancements
6+
- Improved exception messages when multiple `ErrorMsg` are received by the `Live` client
67
- Upgraded `databento-dbn` to 0.17.0
78

89
#### Bug fixes

databento/live/protocol.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(
8282

8383
self._authenticated: asyncio.Future[str | None] = asyncio.Future()
8484
self._disconnected: asyncio.Future[None] = asyncio.Future()
85+
self._error_msgs: list[str] = []
8586
self._started: bool = False
8687

8788
@property
@@ -323,15 +324,22 @@ def _process_dbn(self, data: bytes) -> None:
323324
if isinstance(record, databento_dbn.Metadata):
324325
self.received_metadata(record)
325326
continue
326-
327327
if isinstance(record, databento_dbn.ErrorMsg):
328328
logger.error(
329329
"gateway error: %s",
330330
record.err,
331331
)
332-
self.disconnected.set_exception(
333-
BentoError(record.err),
334-
)
332+
self._error_msgs.append(record.err)
333+
if record.is_last:
334+
if len(self._error_msgs) > 1:
335+
errors = ", ".join(self._error_msgs)
336+
error_msg = f"The following errors occurred: {errors}"
337+
else:
338+
error_msg = self._error_msgs[-1]
339+
self._error_msgs.clear()
340+
self.disconnected.set_exception(
341+
BentoError(error_msg),
342+
)
335343
if isinstance(record, databento_dbn.SystemMsg):
336344
if record.is_heartbeat:
337345
logger.debug("gateway heartbeat")

0 commit comments

Comments
 (0)