Skip to content

Add a GroupNotFoundError #3066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -837,7 +837,7 @@
overwrite=overwrite,
attributes=attributes,
)
raise FileNotFoundError(f"Unable to find group: {store_path}")
raise GroupNotFoundError(store, store_path.path)

Check warning on line 840 in src/zarr/api/asynchronous.py

View check run for this annotation

Codecov / codecov/patch

src/zarr/api/asynchronous.py#L840

Added line #L840 was not covered by tests


async def create(
Expand Down
10 changes: 9 additions & 1 deletion src/zarr/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
]


class BaseZarrError(ValueError):
class BaseZarrError(Exception):
"""
Base error which all zarr errors are sub-classed from.
"""
Expand All @@ -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."""

Expand Down
Loading