diff --git a/src/zarr/api/asynchronous.py b/src/zarr/api/asynchronous.py index cdedd5b033..327aaa68cc 100644 --- a/src/zarr/api/asynchronous.py +++ b/src/zarr/api/asynchronous.py @@ -39,7 +39,7 @@ ) from zarr.core.metadata import ArrayMetadataDict, ArrayV2Metadata, ArrayV3Metadata from zarr.core.metadata.v2 import _default_compressor, _default_filters -from zarr.errors import NodeTypeValidationError +from zarr.errors import GroupNotFoundError, NodeTypeValidationError from zarr.storage._common import make_store_path if TYPE_CHECKING: @@ -837,7 +837,7 @@ async def open_group( overwrite=overwrite, attributes=attributes, ) - raise FileNotFoundError(f"Unable to find group: {store_path}") + raise GroupNotFoundError(store, store_path.path) async def create( diff --git a/src/zarr/errors.py b/src/zarr/errors.py index 441cdab9a3..31071fff81 100644 --- a/src/zarr/errors.py +++ b/src/zarr/errors.py @@ -10,7 +10,7 @@ ] -class BaseZarrError(ValueError): +class BaseZarrError(Exception): """ Base error which all zarr errors are sub-classed from. """ @@ -21,6 +21,14 @@ def __init__(self, *args: Any) -> None: super().__init__(self._msg.format(*args)) +class GroupNotFoundError(BaseZarrError, FileNotFoundError): + """ + Raised when a group isn't found at a certain path. + """ + + _msg = "No group found in store {!r} at path {!r}" + + class ContainsGroupError(BaseZarrError): """Raised when a group already exists at a certain path."""