Skip to content

Commit 5d8f611

Browse files
committed
Add a GroupNotFoundError
1 parent d57fbf7 commit 5d8f611

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/zarr/api/asynchronous.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from zarr.core.metadata import ArrayMetadataDict, ArrayV2Metadata, ArrayV3Metadata
4141
from zarr.core.metadata.v2 import _default_compressor, _default_filters
42-
from zarr.errors import NodeTypeValidationError
42+
from zarr.errors import GroupNotFoundError, NodeTypeValidationError
4343
from zarr.storage._common import make_store_path
4444

4545
if TYPE_CHECKING:
@@ -837,7 +837,7 @@ async def open_group(
837837
overwrite=overwrite,
838838
attributes=attributes,
839839
)
840-
raise FileNotFoundError(f"Unable to find group: {store_path}")
840+
raise GroupNotFoundError(store, store_path.path)
841841

842842

843843
async def create(

src/zarr/errors.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
]
1111

1212

13-
class BaseZarrError(ValueError):
13+
class BaseZarrError(Exception):
1414
"""
1515
Base error which all zarr errors are sub-classed from.
1616
"""
@@ -21,6 +21,14 @@ def __init__(self, *args: Any) -> None:
2121
super().__init__(self._msg.format(*args))
2222

2323

24+
class GroupNotFoundError(BaseZarrError, FileNotFoundError):
25+
"""
26+
Raised when a group isn't found at a certain path.
27+
"""
28+
29+
_msg = "No group found in store {!r} at path {!r}"
30+
31+
2432
class ContainsGroupError(BaseZarrError):
2533
"""Raised when a group already exists at a certain path."""
2634

0 commit comments

Comments
 (0)