python-custom-exceptions 0.0.2__tar.gz → 1.0.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.
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/MANIFEST.in +1 -1
- python_custom_exceptions-1.0.0/PKG-INFO +154 -0
- python_custom_exceptions-1.0.0/README.md +133 -0
- python_custom_exceptions-1.0.0/pyproject.toml +47 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/__init__.py +37 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/comparison_exception.py +20 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/execution_exception.py +15 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/is_exist_exception.py +55 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/operation_exception.py +40 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/os_exceptions.py +14 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/unsupported_exception.py +14 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions/wrong_exception.py +14 -0
- python_custom_exceptions-1.0.0/python_custom_exceptions.egg-info/PKG-INFO +154 -0
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/python_custom_exceptions.egg-info/SOURCES.txt +7 -2
- python_custom_exceptions-1.0.0/python_custom_exceptions.egg-info/requires.txt +1 -0
- python_custom_exceptions-1.0.0/tests/test_diagnostic_info.py +206 -0
- python_custom_exceptions-1.0.0/tests/test_exception.py +103 -0
- python_custom_exceptions-0.0.2/PKG-INFO +0 -89
- python_custom_exceptions-0.0.2/README.md +0 -58
- python_custom_exceptions-0.0.2/pyproject.toml +0 -3
- python_custom_exceptions-0.0.2/python_custom_exceptions/__init__.py +0 -15
- python_custom_exceptions-0.0.2/python_custom_exceptions/is_exist_exception.py +0 -27
- python_custom_exceptions-0.0.2/python_custom_exceptions.egg-info/PKG-INFO +0 -89
- python_custom_exceptions-0.0.2/python_custom_exceptions.egg-info/requires.txt +0 -10
- python_custom_exceptions-0.0.2/requirements.txt +0 -11
- python_custom_exceptions-0.0.2/setup.py +0 -35
- python_custom_exceptions-0.0.2/tests/test_exception.py +0 -22
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/LICENSE +0 -0
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/python_custom_exceptions/base_custom_exception.py +0 -0
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/python_custom_exceptions/connection_exceptions.py +0 -0
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/python_custom_exceptions.egg-info/dependency_links.txt +0 -0
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/python_custom_exceptions.egg-info/top_level.txt +0 -0
- {python_custom_exceptions-0.0.2 → python_custom_exceptions-1.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-custom-exceptions
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A collection of custom exceptions for Python projects.
|
|
5
|
+
Author: Avi Zaguri
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/aviz92/python-custom-exceptions
|
|
8
|
+
Project-URL: Repository, https://github.com/aviz92/python-custom-exceptions
|
|
9
|
+
Project-URL: Issues, https://github.com/aviz92/python-custom-exceptions/issues
|
|
10
|
+
Keywords: development,python,exceptions,error-handling
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: python-base-toolkit>=1.1.3
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Python Custom Exceptions
|
|
23
|
+
A collection of structured, ready-to-use exception classes for Python projects. <br>
|
|
24
|
+
Every exception renders as JSON with its type, a human-readable message, and optional diagnostic info,
|
|
25
|
+
so errors are easy to read in logs and easy to parse by tools. <br>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
- ✅ Specific Exception Classes: Ready-made exceptions for common error scenarios.
|
|
31
|
+
- ✅ Structured Output: `str(exception)` is a JSON document with type, message and diagnostic info.
|
|
32
|
+
- ✅ Diagnostic Info: Attach typed context (`TypedDict`, `dict` or dataclass) to any exception.
|
|
33
|
+
- ✅ Single Base Class: Everything inherits from `BaseCustomException`, so one `except` catches them all.
|
|
34
|
+
- ✅ Easy Extension: Subclass `BaseCustomException` to add your own exceptions.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### Installation
|
|
39
|
+
```bash
|
|
40
|
+
uv add python-custom-exceptions
|
|
41
|
+
```
|
|
42
|
+
or with pip:
|
|
43
|
+
```bash
|
|
44
|
+
pip install python-custom-exceptions
|
|
45
|
+
```
|
|
46
|
+
Requires Python 3.12+.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### Available Exceptions
|
|
51
|
+
| Exception | Arguments | Message |
|
|
52
|
+
|-----------|-----------|---------|
|
|
53
|
+
| `BaseCustomException` | `message_with_marking_dynamic_variables` | `<message>` |
|
|
54
|
+
| `ComparisonException` | `expected_value`, `actual_value`, `subject=None` | `Expected <subject> to be [<expected>], but got [<actual>]` |
|
|
55
|
+
| `ConnectionException` | `host`, `message=None` | `Connection failed: Unable to establish a connection to the remote host ["<host>"]. ...` |
|
|
56
|
+
| `IsExistException` | `subject` | `[<subject>] is exists` |
|
|
57
|
+
| `IsNotExistException` | `subject` | `[<subject>] is not exists` |
|
|
58
|
+
| `IsExistAfterOperationException` | `subject`, `operation` | `<subject> exists after trying to <operation>` |
|
|
59
|
+
| `IsNotExistAfterOperationException` | `subject`, `operation` | `<subject> does not exist after trying to <operation>` |
|
|
60
|
+
| `OperationException` | `operation` | `Operation <operation> failed` |
|
|
61
|
+
| `NotOperationalException` | `subject` | `<subject> is not Operational` |
|
|
62
|
+
| `UnexpectedlySucceededOperationException` | `operation` | `Operation <operation> unexpectedly succeeded` |
|
|
63
|
+
| `TimedExecutionException` | `operation`, `timeout` | `Operation <operation> did not succeed within [<timeout>] seconds` |
|
|
64
|
+
| `UnsupportedExceptions` | `unsupported_subject` | `<unsupported_subject> is unsupported` |
|
|
65
|
+
| `UnsupportedOSExceptions` | `os_name` | `Unsupported OS: ["<os_name>"]` |
|
|
66
|
+
| `WrongUsageException` | `message` | `Wrong usage: <message>` |
|
|
67
|
+
|
|
68
|
+
All exceptions also accept an optional `diagnostic_info` argument.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Usage Examples
|
|
73
|
+
|
|
74
|
+
#### Raise an exception with diagnostic info
|
|
75
|
+
```python
|
|
76
|
+
from pathlib import Path
|
|
77
|
+
|
|
78
|
+
from python_custom_exceptions import DiagnosticInfo, IsNotExistException
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class PathDiagnosticInfo(DiagnosticInfo):
|
|
82
|
+
path: str
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
path = Path("/tmp/missing")
|
|
86
|
+
if not path.exists():
|
|
87
|
+
raise IsNotExistException(
|
|
88
|
+
subject="Directory",
|
|
89
|
+
diagnostic_info=PathDiagnosticInfo(path=str(path)),
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
Output:
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"exception_type": "IsNotExistException",
|
|
96
|
+
"message": "[Directory] is not exists",
|
|
97
|
+
"diagnostic_info": {
|
|
98
|
+
"path": "/tmp/missing"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Catch any custom exception
|
|
104
|
+
```python
|
|
105
|
+
from python_custom_exceptions import BaseCustomException, ComparisonException
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
raise ComparisonException(expected_value=200, actual_value=500, subject="status code")
|
|
109
|
+
except BaseCustomException as exc:
|
|
110
|
+
print(exc.exception_type) # ComparisonException
|
|
111
|
+
print(exc.message) # Expected status code to be [200], but got [500]
|
|
112
|
+
print(exc.diagnostic_info) # {}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Define your own exception
|
|
116
|
+
```python
|
|
117
|
+
from python_custom_exceptions import BaseCustomException, DiagnosticInfo
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class QuotaExceededException(BaseCustomException):
|
|
121
|
+
def __init__(self, resource: str, limit: int, diagnostic_info: dict | DiagnosticInfo | None = None) -> None:
|
|
122
|
+
super().__init__(
|
|
123
|
+
message_with_marking_dynamic_variables=f"Quota for [{resource}] exceeded the limit of [{limit}]",
|
|
124
|
+
diagnostic_info=diagnostic_info,
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### Development
|
|
131
|
+
```bash
|
|
132
|
+
git clone https://github.com/aviz92/python-custom-exceptions.git
|
|
133
|
+
cd python-custom-exceptions
|
|
134
|
+
uv sync # create .venv and install runtime + dev dependencies
|
|
135
|
+
uv run pre-commit install # enable git hooks
|
|
136
|
+
uv run pytest # run the tests
|
|
137
|
+
uv build # build sdist + wheel into dist/
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### 🤝 Contributing
|
|
143
|
+
If you have a helpful exception, pattern, or improvement to suggest:
|
|
144
|
+
1. Fork the repo
|
|
145
|
+
2. Create a new branch
|
|
146
|
+
3. Submit a pull request
|
|
147
|
+
|
|
148
|
+
I welcome additions that promote clean, productive, and maintainable development. <br>
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### 🙏 Thanks
|
|
153
|
+
Thanks for exploring this repository! <br>
|
|
154
|
+
Happy coding! <br>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Python Custom Exceptions
|
|
2
|
+
A collection of structured, ready-to-use exception classes for Python projects. <br>
|
|
3
|
+
Every exception renders as JSON with its type, a human-readable message, and optional diagnostic info,
|
|
4
|
+
so errors are easy to read in logs and easy to parse by tools. <br>
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
- ✅ Specific Exception Classes: Ready-made exceptions for common error scenarios.
|
|
10
|
+
- ✅ Structured Output: `str(exception)` is a JSON document with type, message and diagnostic info.
|
|
11
|
+
- ✅ Diagnostic Info: Attach typed context (`TypedDict`, `dict` or dataclass) to any exception.
|
|
12
|
+
- ✅ Single Base Class: Everything inherits from `BaseCustomException`, so one `except` catches them all.
|
|
13
|
+
- ✅ Easy Extension: Subclass `BaseCustomException` to add your own exceptions.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
```bash
|
|
19
|
+
uv add python-custom-exceptions
|
|
20
|
+
```
|
|
21
|
+
or with pip:
|
|
22
|
+
```bash
|
|
23
|
+
pip install python-custom-exceptions
|
|
24
|
+
```
|
|
25
|
+
Requires Python 3.12+.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Available Exceptions
|
|
30
|
+
| Exception | Arguments | Message |
|
|
31
|
+
|-----------|-----------|---------|
|
|
32
|
+
| `BaseCustomException` | `message_with_marking_dynamic_variables` | `<message>` |
|
|
33
|
+
| `ComparisonException` | `expected_value`, `actual_value`, `subject=None` | `Expected <subject> to be [<expected>], but got [<actual>]` |
|
|
34
|
+
| `ConnectionException` | `host`, `message=None` | `Connection failed: Unable to establish a connection to the remote host ["<host>"]. ...` |
|
|
35
|
+
| `IsExistException` | `subject` | `[<subject>] is exists` |
|
|
36
|
+
| `IsNotExistException` | `subject` | `[<subject>] is not exists` |
|
|
37
|
+
| `IsExistAfterOperationException` | `subject`, `operation` | `<subject> exists after trying to <operation>` |
|
|
38
|
+
| `IsNotExistAfterOperationException` | `subject`, `operation` | `<subject> does not exist after trying to <operation>` |
|
|
39
|
+
| `OperationException` | `operation` | `Operation <operation> failed` |
|
|
40
|
+
| `NotOperationalException` | `subject` | `<subject> is not Operational` |
|
|
41
|
+
| `UnexpectedlySucceededOperationException` | `operation` | `Operation <operation> unexpectedly succeeded` |
|
|
42
|
+
| `TimedExecutionException` | `operation`, `timeout` | `Operation <operation> did not succeed within [<timeout>] seconds` |
|
|
43
|
+
| `UnsupportedExceptions` | `unsupported_subject` | `<unsupported_subject> is unsupported` |
|
|
44
|
+
| `UnsupportedOSExceptions` | `os_name` | `Unsupported OS: ["<os_name>"]` |
|
|
45
|
+
| `WrongUsageException` | `message` | `Wrong usage: <message>` |
|
|
46
|
+
|
|
47
|
+
All exceptions also accept an optional `diagnostic_info` argument.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### Usage Examples
|
|
52
|
+
|
|
53
|
+
#### Raise an exception with diagnostic info
|
|
54
|
+
```python
|
|
55
|
+
from pathlib import Path
|
|
56
|
+
|
|
57
|
+
from python_custom_exceptions import DiagnosticInfo, IsNotExistException
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class PathDiagnosticInfo(DiagnosticInfo):
|
|
61
|
+
path: str
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
path = Path("/tmp/missing")
|
|
65
|
+
if not path.exists():
|
|
66
|
+
raise IsNotExistException(
|
|
67
|
+
subject="Directory",
|
|
68
|
+
diagnostic_info=PathDiagnosticInfo(path=str(path)),
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
Output:
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"exception_type": "IsNotExistException",
|
|
75
|
+
"message": "[Directory] is not exists",
|
|
76
|
+
"diagnostic_info": {
|
|
77
|
+
"path": "/tmp/missing"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Catch any custom exception
|
|
83
|
+
```python
|
|
84
|
+
from python_custom_exceptions import BaseCustomException, ComparisonException
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
raise ComparisonException(expected_value=200, actual_value=500, subject="status code")
|
|
88
|
+
except BaseCustomException as exc:
|
|
89
|
+
print(exc.exception_type) # ComparisonException
|
|
90
|
+
print(exc.message) # Expected status code to be [200], but got [500]
|
|
91
|
+
print(exc.diagnostic_info) # {}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Define your own exception
|
|
95
|
+
```python
|
|
96
|
+
from python_custom_exceptions import BaseCustomException, DiagnosticInfo
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class QuotaExceededException(BaseCustomException):
|
|
100
|
+
def __init__(self, resource: str, limit: int, diagnostic_info: dict | DiagnosticInfo | None = None) -> None:
|
|
101
|
+
super().__init__(
|
|
102
|
+
message_with_marking_dynamic_variables=f"Quota for [{resource}] exceeded the limit of [{limit}]",
|
|
103
|
+
diagnostic_info=diagnostic_info,
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### Development
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/aviz92/python-custom-exceptions.git
|
|
112
|
+
cd python-custom-exceptions
|
|
113
|
+
uv sync # create .venv and install runtime + dev dependencies
|
|
114
|
+
uv run pre-commit install # enable git hooks
|
|
115
|
+
uv run pytest # run the tests
|
|
116
|
+
uv build # build sdist + wheel into dist/
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### 🤝 Contributing
|
|
122
|
+
If you have a helpful exception, pattern, or improvement to suggest:
|
|
123
|
+
1. Fork the repo
|
|
124
|
+
2. Create a new branch
|
|
125
|
+
3. Submit a pull request
|
|
126
|
+
|
|
127
|
+
I welcome additions that promote clean, productive, and maintainable development. <br>
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### 🙏 Thanks
|
|
132
|
+
Thanks for exploring this repository! <br>
|
|
133
|
+
Happy coding! <br>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "python-custom-exceptions"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "A collection of custom exceptions for Python projects."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Avi Zaguri" },]
|
|
13
|
+
keywords = ["development", "python", "exceptions", "error-handling"]
|
|
14
|
+
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
dependencies = [
|
|
24
|
+
"python-base-toolkit>=1.1.3",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[dependency-groups]
|
|
28
|
+
dev = [
|
|
29
|
+
"pytest-better-report>=1.0.2",
|
|
30
|
+
"custom-python-logger>=4.1.0",
|
|
31
|
+
"pre-commit>=4.7.0",
|
|
32
|
+
"pytest>=9.2.0",
|
|
33
|
+
"python-dotenv>=1.2.4",
|
|
34
|
+
"setuptools>=84.2.1",
|
|
35
|
+
"wheel>=0.48.0",
|
|
36
|
+
"python-base-command>=0.1.8",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/aviz92/python-custom-exceptions"
|
|
41
|
+
Repository = "https://github.com/aviz92/python-custom-exceptions"
|
|
42
|
+
Issues = "https://github.com/aviz92/python-custom-exceptions/issues"
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
where = ["."]
|
|
46
|
+
include = ["python_custom_exceptions*"]
|
|
47
|
+
namespaces = false
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo, serialize_data
|
|
2
|
+
from python_custom_exceptions.comparison_exception import ComparisonException
|
|
3
|
+
from python_custom_exceptions.connection_exceptions import ConnectionException
|
|
4
|
+
from python_custom_exceptions.execution_exception import TimedExecutionException
|
|
5
|
+
from python_custom_exceptions.is_exist_exception import (
|
|
6
|
+
IsExistAfterOperationException,
|
|
7
|
+
IsExistException,
|
|
8
|
+
IsNotExistAfterOperationException,
|
|
9
|
+
IsNotExistException,
|
|
10
|
+
)
|
|
11
|
+
from python_custom_exceptions.operation_exception import (
|
|
12
|
+
NotOperationalException,
|
|
13
|
+
OperationException,
|
|
14
|
+
UnexpectedlySucceededOperationException,
|
|
15
|
+
)
|
|
16
|
+
from python_custom_exceptions.os_exceptions import UnsupportedOSExceptions
|
|
17
|
+
from python_custom_exceptions.unsupported_exception import UnsupportedExceptions
|
|
18
|
+
from python_custom_exceptions.wrong_exception import WrongUsageException
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"BaseCustomException",
|
|
22
|
+
"DiagnosticInfo",
|
|
23
|
+
"serialize_data",
|
|
24
|
+
"ConnectionException",
|
|
25
|
+
"ComparisonException",
|
|
26
|
+
"IsExistAfterOperationException",
|
|
27
|
+
"IsExistException",
|
|
28
|
+
"IsNotExistException",
|
|
29
|
+
"IsNotExistAfterOperationException",
|
|
30
|
+
"NotOperationalException",
|
|
31
|
+
"OperationException",
|
|
32
|
+
"TimedExecutionException",
|
|
33
|
+
"UnexpectedlySucceededOperationException",
|
|
34
|
+
"UnsupportedExceptions",
|
|
35
|
+
"WrongUsageException",
|
|
36
|
+
"UnsupportedOSExceptions",
|
|
37
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ComparisonException(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
expected_value: int,
|
|
8
|
+
actual_value: int,
|
|
9
|
+
subject: str | None = None,
|
|
10
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
11
|
+
) -> None:
|
|
12
|
+
message = (
|
|
13
|
+
f"Expected {subject} to be [{expected_value}], but got [{actual_value}]"
|
|
14
|
+
if subject
|
|
15
|
+
else f"Expected [{expected_value}], but got [{actual_value}]"
|
|
16
|
+
)
|
|
17
|
+
super().__init__(
|
|
18
|
+
message_with_marking_dynamic_variables=message,
|
|
19
|
+
diagnostic_info=diagnostic_info,
|
|
20
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class TimedExecutionException(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
operation: str,
|
|
8
|
+
timeout: str | int,
|
|
9
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
10
|
+
) -> None:
|
|
11
|
+
message = f"Operation {operation} did not succeed within [{timeout}] seconds"
|
|
12
|
+
super().__init__(
|
|
13
|
+
message_with_marking_dynamic_variables=message,
|
|
14
|
+
diagnostic_info=diagnostic_info,
|
|
15
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class IsExistException(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
subject: str,
|
|
8
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
9
|
+
) -> None:
|
|
10
|
+
message = f"[{subject}] is exists"
|
|
11
|
+
super().__init__(
|
|
12
|
+
message_with_marking_dynamic_variables=message,
|
|
13
|
+
diagnostic_info=diagnostic_info,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class IsNotExistException(BaseCustomException):
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
subject: str,
|
|
21
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
message = f"[{subject}] is not exists"
|
|
24
|
+
super().__init__(
|
|
25
|
+
message_with_marking_dynamic_variables=message,
|
|
26
|
+
diagnostic_info=diagnostic_info,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class IsExistAfterOperationException(BaseCustomException):
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
subject: str,
|
|
34
|
+
operation: str,
|
|
35
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
36
|
+
) -> None:
|
|
37
|
+
message = f"{subject} exists after trying to {operation}"
|
|
38
|
+
super().__init__(
|
|
39
|
+
message_with_marking_dynamic_variables=message,
|
|
40
|
+
diagnostic_info=diagnostic_info,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class IsNotExistAfterOperationException(BaseCustomException):
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
subject: str,
|
|
48
|
+
operation: str,
|
|
49
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
50
|
+
) -> None:
|
|
51
|
+
message = f"{subject} does not exist after trying to {operation}"
|
|
52
|
+
super().__init__(
|
|
53
|
+
message_with_marking_dynamic_variables=message,
|
|
54
|
+
diagnostic_info=diagnostic_info,
|
|
55
|
+
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class OperationException(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
operation: str,
|
|
8
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
9
|
+
) -> None:
|
|
10
|
+
message = f"Operation {operation} failed"
|
|
11
|
+
super().__init__(
|
|
12
|
+
message_with_marking_dynamic_variables=message,
|
|
13
|
+
diagnostic_info=diagnostic_info,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NotOperationalException(BaseCustomException):
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
subject: str,
|
|
21
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
message = f"{subject} is not Operational"
|
|
24
|
+
super().__init__(
|
|
25
|
+
message_with_marking_dynamic_variables=message,
|
|
26
|
+
diagnostic_info=diagnostic_info,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class UnexpectedlySucceededOperationException(BaseCustomException):
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
operation: str,
|
|
34
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
35
|
+
) -> None:
|
|
36
|
+
message = f"Operation {operation} unexpectedly succeeded"
|
|
37
|
+
super().__init__(
|
|
38
|
+
message_with_marking_dynamic_variables=message,
|
|
39
|
+
diagnostic_info=diagnostic_info,
|
|
40
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnsupportedOSExceptions(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
os_name: str,
|
|
8
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
9
|
+
) -> None:
|
|
10
|
+
message = f'Unsupported OS: ["{os_name}"]'
|
|
11
|
+
super().__init__(
|
|
12
|
+
message_with_marking_dynamic_variables=message,
|
|
13
|
+
diagnostic_info=diagnostic_info,
|
|
14
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnsupportedExceptions(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
unsupported_subject: str,
|
|
8
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
9
|
+
) -> None:
|
|
10
|
+
message = f"{unsupported_subject} is unsupported"
|
|
11
|
+
super().__init__(
|
|
12
|
+
message_with_marking_dynamic_variables=message,
|
|
13
|
+
diagnostic_info=diagnostic_info,
|
|
14
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class WrongUsageException(BaseCustomException):
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
message: str,
|
|
8
|
+
diagnostic_info: dict | DiagnosticInfo | None = None,
|
|
9
|
+
) -> None:
|
|
10
|
+
message = f"Wrong usage: {message}"
|
|
11
|
+
super().__init__(
|
|
12
|
+
message_with_marking_dynamic_variables=message,
|
|
13
|
+
diagnostic_info=diagnostic_info,
|
|
14
|
+
)
|