@@ -139,6 +139,11 @@ def __init__(self, source: PathLike[str] | str):
139139 if not self ._path .is_file () or not self ._path .exists ():
140140 raise FileNotFoundError (source )
141141
142+ if self ._path .stat ().st_size == 0 :
143+ raise ValueError (
144+ f"Cannot create data source from empty file: { self ._path .name } " ,
145+ )
146+
142147 self ._name = self ._path .name
143148 self .__buffer : IO [bytes ] | None = None
144149
@@ -308,6 +313,11 @@ class DBNStore:
308313 to_ndarray : np.ndarray
309314 The data as a numpy `ndarray`.
310315
316+ Raises
317+ ------
318+ BentoError
319+ When the data_source does not contain valid DBN data or is corrupted.
320+
311321 See Also
312322 --------
313323 https://docs.databento.com/knowledge-base/new-users/dbn-encoding
@@ -330,7 +340,7 @@ def __init__(self, data_source: DataSource) -> None:
330340 buffer = data_source .reader
331341 else :
332342 # We don't know how to read this file
333- raise RuntimeError (
343+ raise BentoError (
334344 f"Could not determine compression format of { self ._data_source .name } " ,
335345 )
336346
@@ -736,7 +746,9 @@ def from_file(cls, path: PathLike[str] | str) -> DBNStore:
736746 Raises
737747 ------
738748 FileNotFoundError
739- If a empty or non-existant file is specified.
749+ If a non-existant file is specified.
750+ ValueError
751+ If an empty file is specified.
740752
741753 """
742754 return cls (FileDataSource (path ))
@@ -757,8 +769,8 @@ def from_bytes(cls, data: BytesIO | bytes | IO[bytes]) -> DBNStore:
757769
758770 Raises
759771 ------
760- FileNotFoundError
761- If a empty or non-existant file is specified.
772+ ValueError
773+ If an empty buffer is specified.
762774
763775 """
764776 return cls (MemoryDataSource (data ))
0 commit comments