1
1
from typing import Any
2
2
3
+ __all__ = [
4
+ "BaseZarrError" ,
5
+ "ContainsArrayAndGroupError" ,
6
+ "ContainsArrayError" ,
7
+ "ContainsGroupError" ,
8
+ "MetadataValidationError" ,
9
+ "NodeTypeValidationError" ,
10
+ ]
11
+
12
+
13
+ class BaseZarrError (ValueError ):
14
+ """
15
+ Base error which all zarr errors are sub-classed from.
16
+ """
3
17
4
- class _BaseZarrError (ValueError ):
5
18
_msg = ""
6
19
7
20
def __init__ (self , * args : Any ) -> None :
8
21
super ().__init__ (self ._msg .format (* args ))
9
22
10
23
11
- class ContainsGroupError (_BaseZarrError ):
24
+ class ContainsGroupError (BaseZarrError ):
25
+ """Raised when a group already exists at a certain path."""
26
+
12
27
_msg = "A group exists in store {!r} at path {!r}."
13
28
14
29
15
- class ContainsArrayError (_BaseZarrError ):
30
+ class ContainsArrayError (BaseZarrError ):
31
+ """Raised when an array already exists at a certain path."""
32
+
16
33
_msg = "An array exists in store {!r} at path {!r}."
17
34
18
35
19
- class ContainsArrayAndGroupError (_BaseZarrError ):
36
+ class ContainsArrayAndGroupError (BaseZarrError ):
37
+ """Raised when both array and group metadata are found at the same path."""
38
+
20
39
_msg = (
21
40
"Array and group metadata documents (.zarray and .zgroup) were both found in store "
22
41
"{!r} at path {!r}. "
@@ -25,8 +44,8 @@ class ContainsArrayAndGroupError(_BaseZarrError):
25
44
)
26
45
27
46
28
- class MetadataValidationError (_BaseZarrError ):
29
- """An exception raised when the Zarr metadata is invalid in some way"""
47
+ class MetadataValidationError (BaseZarrError ):
48
+ """Raised when the Zarr metadata is invalid in some way"""
30
49
31
50
_msg = "Invalid value for '{}'. Expected '{}'. Got '{}'."
32
51
@@ -38,10 +57,3 @@ class NodeTypeValidationError(MetadataValidationError):
38
57
This can be raised when the value is invalid or unexpected given the context,
39
58
for example an 'array' node when we expected a 'group'.
40
59
"""
41
-
42
-
43
- __all__ = [
44
- "ContainsArrayAndGroupError" ,
45
- "ContainsArrayError" ,
46
- "ContainsGroupError" ,
47
- ]
0 commit comments