exceptions_with_structure 1.0.2__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {exceptions_with_structure-1.0.2 → exceptions_with_structure-1.1.0}/PKG-INFO +1 -1
- {exceptions_with_structure-1.0.2 → exceptions_with_structure-1.1.0}/pyproject.toml +1 -1
- exceptions_with_structure-1.1.0/src/py/Exceptions.py +43 -0
- exceptions_with_structure-1.0.2/src/py/Exceptions.py +0 -12
- {exceptions_with_structure-1.0.2 → exceptions_with_structure-1.1.0}/.gitignore +0 -0
- {exceptions_with_structure-1.0.2 → exceptions_with_structure-1.1.0}/README.md +0 -0
- {exceptions_with_structure-1.0.2 → exceptions_with_structure-1.1.0}/src/py/__init__.py +0 -0
- {exceptions_with_structure-1.0.2 → exceptions_with_structure-1.1.0}/src/py/utils.py +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from .utils import iso8601
|
|
2
|
+
|
|
3
|
+
class StructuredException(Exception):
|
|
4
|
+
"""Base class for all structured errors."""
|
|
5
|
+
def __init__(self, message: str, error_code: str):
|
|
6
|
+
super().__init__(message)
|
|
7
|
+
self.timestamp = iso8601()
|
|
8
|
+
self.error_code = error_code
|
|
9
|
+
|
|
10
|
+
# Dynamically create specific error types to avoid code duplication
|
|
11
|
+
def _create_structured_error(base_class: type[Exception], name: str) -> type[StructuredException]:
|
|
12
|
+
class NewStructuredError(StructuredException, base_class):
|
|
13
|
+
pass
|
|
14
|
+
NewStructuredError.__name__ = name
|
|
15
|
+
NewStructuredError.__qualname__ = name
|
|
16
|
+
return NewStructuredError
|
|
17
|
+
|
|
18
|
+
StructuredKeyError = _create_structured_error(KeyError, "StructuredKeyError")
|
|
19
|
+
StructuredTabError = _create_structured_error(TabError, "StructuredTabError")
|
|
20
|
+
StructuredNameError = _create_structured_error(NameError, "StructuredNameError")
|
|
21
|
+
StructuredTypeError = _create_structured_error(TypeError, "StructuredTypeError")
|
|
22
|
+
StructuredValueError = _create_structured_error(ValueError, "StructuredValueError")
|
|
23
|
+
StructuredIndexError = _create_structured_error(IndexError, "StructuredIndexError")
|
|
24
|
+
StructuredBufferError = _create_structured_error(BufferError, "StructuredBufferError")
|
|
25
|
+
StructuredEOFError = _create_structured_error(EOFError, "StructuredEOFError")
|
|
26
|
+
StructuredImportError = _create_structured_error(ImportError, "StructuredImportError")
|
|
27
|
+
StructuredLookupError = _create_structured_error(LookupError, "StructuredLookupError")
|
|
28
|
+
StructuredMemoryError = _create_structured_error(MemoryError, "StructuredMemoryError")
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"StructuredException",
|
|
32
|
+
"StructuredKeyError",
|
|
33
|
+
"StructuredTabError",
|
|
34
|
+
"StructuredNameError",
|
|
35
|
+
"StructuredTypeError",
|
|
36
|
+
"StructuredValueError",
|
|
37
|
+
"StructuredIndexError",
|
|
38
|
+
"StructuredBufferError",
|
|
39
|
+
"StructuredEOFError",
|
|
40
|
+
"StructuredImportError",
|
|
41
|
+
"StructuredLookupError",
|
|
42
|
+
"StructuredMemoryError",
|
|
43
|
+
]
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from .utils import iso8601
|
|
2
|
-
|
|
3
|
-
class StructuredException(Exception):
|
|
4
|
-
def __init__(self, message: str, error_code: str):
|
|
5
|
-
# Pass the message to the parent Exception class
|
|
6
|
-
super().__init__(message)
|
|
7
|
-
|
|
8
|
-
# Store your custom fields
|
|
9
|
-
self.timestamp = iso8601()
|
|
10
|
-
self.error_code = error_code
|
|
11
|
-
|
|
12
|
-
__all__ = ["StructuredException"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|