python-custom-exceptions 0.0.1__tar.gz → 0.0.2__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.
Files changed (23) hide show
  1. python_custom_exceptions-0.0.2/PKG-INFO +89 -0
  2. python_custom_exceptions-0.0.2/README.md +58 -0
  3. python_custom_exceptions-0.0.2/python_custom_exceptions/__init__.py +15 -0
  4. python_custom_exceptions-0.0.2/python_custom_exceptions/base_custom_exception.py +46 -0
  5. python_custom_exceptions-0.0.2/python_custom_exceptions/connection_exceptions.py +23 -0
  6. python_custom_exceptions-0.0.2/python_custom_exceptions/is_exist_exception.py +27 -0
  7. python_custom_exceptions-0.0.2/python_custom_exceptions.egg-info/PKG-INFO +89 -0
  8. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/python_custom_exceptions.egg-info/SOURCES.txt +6 -1
  9. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/python_custom_exceptions.egg-info/requires.txt +4 -0
  10. python_custom_exceptions-0.0.2/python_custom_exceptions.egg-info/top_level.txt +1 -0
  11. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/requirements.txt +4 -0
  12. python_custom_exceptions-0.0.2/setup.py +35 -0
  13. python_custom_exceptions-0.0.2/tests/test_exception.py +22 -0
  14. python_custom_exceptions-0.0.1/PKG-INFO +0 -43
  15. python_custom_exceptions-0.0.1/README.md +0 -16
  16. python_custom_exceptions-0.0.1/python_custom_exceptions.egg-info/PKG-INFO +0 -43
  17. python_custom_exceptions-0.0.1/python_custom_exceptions.egg-info/top_level.txt +0 -1
  18. python_custom_exceptions-0.0.1/setup.py +0 -37
  19. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/LICENSE +0 -0
  20. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/MANIFEST.in +0 -0
  21. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/pyproject.toml +0 -0
  22. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/python_custom_exceptions.egg-info/dependency_links.txt +0 -0
  23. {python_custom_exceptions-0.0.1 → python_custom_exceptions-0.0.2}/setup.cfg +0 -0
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-custom-exceptions
3
+ Version: 0.0.2
4
+ Summary: A collection of custom exceptions for Python projects.
5
+ Home-page: https://github.com/aviz92/python-custom-exceptions
6
+ Author: Avi Zaguri
7
+ Author-email:
8
+ Project-URL: Repository, https://github.com/aviz92/python-custom-exceptions
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: setuptools
13
+ Requires-Dist: wheel
14
+ Requires-Dist: python-dotenv
15
+ Requires-Dist: pre-commit
16
+ Requires-Dist: colorlog
17
+ Requires-Dist: pytest
18
+ Requires-Dist: pathlib
19
+ Requires-Dist: pytest-plugins
20
+ Requires-Dist: custom-python-logger
21
+ Requires-Dist: python-base-toolkit
22
+ Dynamic: author
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: project-url
28
+ Dynamic: requires-dist
29
+ Dynamic: requires-python
30
+ Dynamic: summary
31
+
32
+ # Python Custom Exceptions
33
+ A repository containing custom exception classes for Python projects. <br>
34
+ These exceptions are designed to provide more specific error handling and improve code readability.
35
+ They can be easily integrated into any Python application to enhance error management. <br>
36
+
37
+ ---
38
+
39
+ ### Features
40
+ - ✅ Specific Exception Classes: Custom exceptions for various error scenarios.
41
+ - ✅ Improved Readability: Clearer error handling in code.
42
+ - ✅ Easy Integration: Simple to add to existing Python projects.
43
+ - ✅ Standardized Error Handling: Consistent approach to managing exceptions.
44
+ - ✅ Structured Hierarchy: Organized exception classes for better maintainability.
45
+
46
+ ---
47
+
48
+ ### Installation
49
+ ```bash
50
+ pip install python-custom-exceptions
51
+ ```
52
+
53
+ ---
54
+
55
+ ### Usage Examples
56
+ ```python
57
+ import os
58
+ from python_custom_exceptions import DiagnosticInfo, IsNotExistException
59
+
60
+
61
+ class DiagnosticInfoTest(DiagnosticInfo):
62
+ file_path: str
63
+
64
+
65
+ file_path = "test_dir"
66
+ os.mkdir(file_path)
67
+ if not os.path.exists(file_path):
68
+ raise IsNotExistException(
69
+ subject="Directory",
70
+ diagnostic_info=DiagnosticInfoTest(
71
+ file_path=file_path
72
+ )
73
+ )
74
+ ```
75
+
76
+ ---
77
+
78
+ ### 🤝 Contributing
79
+ If you have a helpful tool, pattern, or improvement to suggest:
80
+ Fork the repo <br>
81
+ Create a new branch <br>
82
+ Submit a pull request <br>
83
+ I welcome additions that promote clean, productive, and maintainable development. <br>
84
+
85
+ ---
86
+
87
+ ### 🙏 Thanks
88
+ Thanks for exploring this repository! <br>
89
+ Happy coding! <br>
@@ -0,0 +1,58 @@
1
+ # Python Custom Exceptions
2
+ A repository containing custom exception classes for Python projects. <br>
3
+ These exceptions are designed to provide more specific error handling and improve code readability.
4
+ They can be easily integrated into any Python application to enhance error management. <br>
5
+
6
+ ---
7
+
8
+ ### Features
9
+ - ✅ Specific Exception Classes: Custom exceptions for various error scenarios.
10
+ - ✅ Improved Readability: Clearer error handling in code.
11
+ - ✅ Easy Integration: Simple to add to existing Python projects.
12
+ - ✅ Standardized Error Handling: Consistent approach to managing exceptions.
13
+ - ✅ Structured Hierarchy: Organized exception classes for better maintainability.
14
+
15
+ ---
16
+
17
+ ### Installation
18
+ ```bash
19
+ pip install python-custom-exceptions
20
+ ```
21
+
22
+ ---
23
+
24
+ ### Usage Examples
25
+ ```python
26
+ import os
27
+ from python_custom_exceptions import DiagnosticInfo, IsNotExistException
28
+
29
+
30
+ class DiagnosticInfoTest(DiagnosticInfo):
31
+ file_path: str
32
+
33
+
34
+ file_path = "test_dir"
35
+ os.mkdir(file_path)
36
+ if not os.path.exists(file_path):
37
+ raise IsNotExistException(
38
+ subject="Directory",
39
+ diagnostic_info=DiagnosticInfoTest(
40
+ file_path=file_path
41
+ )
42
+ )
43
+ ```
44
+
45
+ ---
46
+
47
+ ### 🤝 Contributing
48
+ If you have a helpful tool, pattern, or improvement to suggest:
49
+ Fork the repo <br>
50
+ Create a new branch <br>
51
+ Submit a pull request <br>
52
+ I welcome additions that promote clean, productive, and maintainable development. <br>
53
+
54
+ ---
55
+
56
+ ### 🙏 Thanks
57
+ Thanks for exploring this repository! <br>
58
+ Happy coding! <br>
@@ -0,0 +1,15 @@
1
+ from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo, serialize_data
2
+ from python_custom_exceptions.connection_exceptions import ConnectionException
3
+ from python_custom_exceptions.is_exist_exception import (
4
+ IsExistException,
5
+ IsNotExistException,
6
+ )
7
+
8
+ __all__ = [
9
+ "BaseCustomException",
10
+ "DiagnosticInfo",
11
+ "serialize_data",
12
+ "ConnectionException",
13
+ "IsExistException",
14
+ "IsNotExistException",
15
+ ]
@@ -0,0 +1,46 @@
1
+ import json
2
+ from dataclasses import is_dataclass
3
+ from json import dumps
4
+ from typing import TypedDict
5
+
6
+ from python_base_toolkit.utils.data_serialization import default_serialize
7
+
8
+
9
+ class DiagnosticInfo(TypedDict): ...
10
+
11
+
12
+ def serialize_data(obj: object) -> dict:
13
+ return json.loads(json.dumps(obj, default=default_serialize))
14
+
15
+
16
+ def get_full_exception_message(content: dict) -> str:
17
+ return (
18
+ f'{content["message"]}\n\nCustom Exception Raised!\n'
19
+ f"{dumps(content, indent=4, sort_keys=False, default=str)}"
20
+ )
21
+
22
+
23
+ class BaseCustomException(Exception):
24
+ def __init__(
25
+ self,
26
+ message_with_marking_dynamic_variables: str,
27
+ diagnostic_info: dict | DiagnosticInfo | None = None,
28
+ ) -> None:
29
+ if is_dataclass(diagnostic_info):
30
+ diagnostic_info = diagnostic_info.__dict__
31
+
32
+ self.exception_type = type(self).__name__
33
+ self.message = message_with_marking_dynamic_variables
34
+ self.diagnostic_info = diagnostic_info or {}
35
+
36
+ def __str__(self) -> str:
37
+ exception_content = {
38
+ "exception_type": self.exception_type,
39
+ "message": self.message,
40
+ "diagnostic_info": self.diagnostic_info,
41
+ }
42
+ # return get_full_exception_message(exception_content)
43
+ return dumps(exception_content, indent=4, sort_keys=False, default=str)
44
+
45
+ def __repr__(self) -> str:
46
+ return self.__str__()
@@ -0,0 +1,23 @@
1
+ from python_custom_exceptions.base_custom_exception import BaseCustomException, DiagnosticInfo
2
+
3
+
4
+ class ConnectionException(BaseCustomException):
5
+ def __init__(
6
+ self,
7
+ host: str | None,
8
+ message: str | None = None,
9
+ diagnostic_info: dict | DiagnosticInfo | None = None,
10
+ ) -> None:
11
+ message = (
12
+ (
13
+ f'Connection failed: Unable to establish a connection to the remote host ["{host}"]. '
14
+ f"Please check your credentials, network status, and host availability."
15
+ )
16
+ if not message
17
+ else message
18
+ )
19
+
20
+ super().__init__(
21
+ message_with_marking_dynamic_variables=message,
22
+ diagnostic_info=diagnostic_info,
23
+ )
@@ -0,0 +1,27 @@
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
+ )
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-custom-exceptions
3
+ Version: 0.0.2
4
+ Summary: A collection of custom exceptions for Python projects.
5
+ Home-page: https://github.com/aviz92/python-custom-exceptions
6
+ Author: Avi Zaguri
7
+ Author-email:
8
+ Project-URL: Repository, https://github.com/aviz92/python-custom-exceptions
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: setuptools
13
+ Requires-Dist: wheel
14
+ Requires-Dist: python-dotenv
15
+ Requires-Dist: pre-commit
16
+ Requires-Dist: colorlog
17
+ Requires-Dist: pytest
18
+ Requires-Dist: pathlib
19
+ Requires-Dist: pytest-plugins
20
+ Requires-Dist: custom-python-logger
21
+ Requires-Dist: python-base-toolkit
22
+ Dynamic: author
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: project-url
28
+ Dynamic: requires-dist
29
+ Dynamic: requires-python
30
+ Dynamic: summary
31
+
32
+ # Python Custom Exceptions
33
+ A repository containing custom exception classes for Python projects. <br>
34
+ These exceptions are designed to provide more specific error handling and improve code readability.
35
+ They can be easily integrated into any Python application to enhance error management. <br>
36
+
37
+ ---
38
+
39
+ ### Features
40
+ - ✅ Specific Exception Classes: Custom exceptions for various error scenarios.
41
+ - ✅ Improved Readability: Clearer error handling in code.
42
+ - ✅ Easy Integration: Simple to add to existing Python projects.
43
+ - ✅ Standardized Error Handling: Consistent approach to managing exceptions.
44
+ - ✅ Structured Hierarchy: Organized exception classes for better maintainability.
45
+
46
+ ---
47
+
48
+ ### Installation
49
+ ```bash
50
+ pip install python-custom-exceptions
51
+ ```
52
+
53
+ ---
54
+
55
+ ### Usage Examples
56
+ ```python
57
+ import os
58
+ from python_custom_exceptions import DiagnosticInfo, IsNotExistException
59
+
60
+
61
+ class DiagnosticInfoTest(DiagnosticInfo):
62
+ file_path: str
63
+
64
+
65
+ file_path = "test_dir"
66
+ os.mkdir(file_path)
67
+ if not os.path.exists(file_path):
68
+ raise IsNotExistException(
69
+ subject="Directory",
70
+ diagnostic_info=DiagnosticInfoTest(
71
+ file_path=file_path
72
+ )
73
+ )
74
+ ```
75
+
76
+ ---
77
+
78
+ ### 🤝 Contributing
79
+ If you have a helpful tool, pattern, or improvement to suggest:
80
+ Fork the repo <br>
81
+ Create a new branch <br>
82
+ Submit a pull request <br>
83
+ I welcome additions that promote clean, productive, and maintainable development. <br>
84
+
85
+ ---
86
+
87
+ ### 🙏 Thanks
88
+ Thanks for exploring this repository! <br>
89
+ Happy coding! <br>
@@ -4,8 +4,13 @@ README.md
4
4
  pyproject.toml
5
5
  requirements.txt
6
6
  setup.py
7
+ python_custom_exceptions/__init__.py
8
+ python_custom_exceptions/base_custom_exception.py
9
+ python_custom_exceptions/connection_exceptions.py
10
+ python_custom_exceptions/is_exist_exception.py
7
11
  python_custom_exceptions.egg-info/PKG-INFO
8
12
  python_custom_exceptions.egg-info/SOURCES.txt
9
13
  python_custom_exceptions.egg-info/dependency_links.txt
10
14
  python_custom_exceptions.egg-info/requires.txt
11
- python_custom_exceptions.egg-info/top_level.txt
15
+ python_custom_exceptions.egg-info/top_level.txt
16
+ tests/test_exception.py
@@ -1,6 +1,10 @@
1
1
  setuptools
2
2
  wheel
3
+ python-dotenv
4
+ pre-commit
3
5
  colorlog
4
6
  pytest
5
7
  pathlib
8
+ pytest-plugins
6
9
  custom-python-logger
10
+ python-base-toolkit
@@ -0,0 +1 @@
1
+ python_custom_exceptions
@@ -1,7 +1,11 @@
1
1
  setuptools
2
2
  wheel
3
+ python-dotenv
4
+ pre-commit
3
5
  colorlog
4
6
  pytest
5
7
  pathlib
6
8
 
9
+ pytest-plugins
7
10
  custom-python-logger
11
+ python-base-toolkit
@@ -0,0 +1,35 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ package_version = "0.0.2"
4
+
5
+ package_name = "python-custom-exceptions"
6
+ package_description = "A collection of custom exceptions for Python projects."
7
+
8
+ package_name_ = package_name.replace("-", "_")
9
+ package_long_description_content_type = "text/markdown"
10
+ package_url = f"https://github.com/aviz92/{package_name}"
11
+ package_python_requires = ">=3.11"
12
+ package_author = "Avi Zaguri"
13
+
14
+ with open("requirements.txt") as file:
15
+ package_install_requires = [line.strip() for line in file.readlines() if line.strip() and not line.startswith("#")]
16
+
17
+ with open("README.md") as file:
18
+ package_long_description = file.read()
19
+
20
+ setup(
21
+ name=package_name,
22
+ version=package_version,
23
+ packages=find_packages(include=[package_name_, f"{package_name_}.*"]),
24
+ install_requires=package_install_requires,
25
+ author=package_author,
26
+ author_email="",
27
+ description=package_description,
28
+ long_description=package_long_description,
29
+ long_description_content_type=package_long_description_content_type,
30
+ url=package_url,
31
+ project_urls={
32
+ "Repository": package_url,
33
+ },
34
+ python_requires=package_python_requires,
35
+ )
@@ -0,0 +1,22 @@
1
+ import pytest
2
+ from custom_python_logger import build_logger
3
+
4
+ from python_custom_exceptions import ConnectionException
5
+
6
+ logger = build_logger(project_name="custom_exceptions_test")
7
+
8
+
9
+ def test_connection_exception():
10
+ with pytest.raises(ConnectionException) as exc_info:
11
+ raise ConnectionException(
12
+ host="Database",
13
+ message="Connection failed",
14
+ diagnostic_info={"host": "db.example.com"},
15
+ )
16
+ logger.info(f"\n{exc_info.value}") # noqa
17
+
18
+
19
+ def test_connection_exception_without_message():
20
+ with pytest.raises(ConnectionException) as exc_info:
21
+ raise ConnectionException(host="Database", diagnostic_info={"host": "db.example.com"})
22
+ logger.info(f"\n{exc_info.value}") # noqa
@@ -1,43 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python-custom-exceptions
3
- Version: 0.0.1
4
- Summary: A collection of custom exceptions for Python projects.
5
- Home-page: https://github.com/aviz92/python-custom-exceptions
6
- Author: Avi Zaguri
7
- Author-email:
8
- Project-URL: Repository, https://github.com/aviz92/python-custom-exceptions
9
- Requires-Python: >=3.11
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: setuptools
13
- Requires-Dist: wheel
14
- Requires-Dist: colorlog
15
- Requires-Dist: pytest
16
- Requires-Dist: pathlib
17
- Requires-Dist: custom-python-logger
18
- Dynamic: author
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
22
- Dynamic: license-file
23
- Dynamic: project-url
24
- Dynamic: requires-dist
25
- Dynamic: requires-python
26
- Dynamic: summary
27
-
28
- # Python Custom Exceptions
29
-
30
- ---
31
-
32
- ## 🤝 Contributing
33
- If you have a helpful tool, pattern, or improvement to suggest:
34
- Fork the repo <br>
35
- Create a new branch <br>
36
- Submit a pull request <br>
37
- I welcome additions that promote clean, productive, and maintainable development. <br>
38
-
39
- ---
40
-
41
- ## 🙏 Thanks
42
- Thanks for exploring this repository! <br>
43
- Happy coding! <br>
@@ -1,16 +0,0 @@
1
- # Python Custom Exceptions
2
-
3
- ---
4
-
5
- ## 🤝 Contributing
6
- If you have a helpful tool, pattern, or improvement to suggest:
7
- Fork the repo <br>
8
- Create a new branch <br>
9
- Submit a pull request <br>
10
- I welcome additions that promote clean, productive, and maintainable development. <br>
11
-
12
- ---
13
-
14
- ## 🙏 Thanks
15
- Thanks for exploring this repository! <br>
16
- Happy coding! <br>
@@ -1,43 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python-custom-exceptions
3
- Version: 0.0.1
4
- Summary: A collection of custom exceptions for Python projects.
5
- Home-page: https://github.com/aviz92/python-custom-exceptions
6
- Author: Avi Zaguri
7
- Author-email:
8
- Project-URL: Repository, https://github.com/aviz92/python-custom-exceptions
9
- Requires-Python: >=3.11
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: setuptools
13
- Requires-Dist: wheel
14
- Requires-Dist: colorlog
15
- Requires-Dist: pytest
16
- Requires-Dist: pathlib
17
- Requires-Dist: custom-python-logger
18
- Dynamic: author
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
22
- Dynamic: license-file
23
- Dynamic: project-url
24
- Dynamic: requires-dist
25
- Dynamic: requires-python
26
- Dynamic: summary
27
-
28
- # Python Custom Exceptions
29
-
30
- ---
31
-
32
- ## 🤝 Contributing
33
- If you have a helpful tool, pattern, or improvement to suggest:
34
- Fork the repo <br>
35
- Create a new branch <br>
36
- Submit a pull request <br>
37
- I welcome additions that promote clean, productive, and maintainable development. <br>
38
-
39
- ---
40
-
41
- ## 🙏 Thanks
42
- Thanks for exploring this repository! <br>
43
- Happy coding! <br>
@@ -1,37 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- package_version = '0.0.1'
4
-
5
- package_name = 'python-custom-exceptions'
6
- package_description = 'A collection of custom exceptions for Python projects.'
7
-
8
- package_name_ = package_name.replace('-', '_')
9
- package_long_description_content_type = 'text/markdown'
10
- package_url = f'https://github.com/aviz92/{package_name}'
11
- package_python_requires = '>=3.11'
12
- package_author = 'Avi Zaguri'
13
-
14
- with open('requirements.txt', 'r') as file:
15
- package_install_requires = [
16
- line.strip() for line in file.readlines() if line.strip() and not line.startswith('#')
17
- ]
18
-
19
- with open('README.md', 'r') as file:
20
- package_long_description = file.read()
21
-
22
- setup(
23
- name=package_name,
24
- version=package_version,
25
- packages=find_packages(include=[package_name_, f'{package_name_}.*']),
26
- install_requires=package_install_requires,
27
- author=package_author,
28
- author_email='',
29
- description=package_description,
30
- long_description=package_long_description,
31
- long_description_content_type=package_long_description_content_type,
32
- url=package_url,
33
- project_urls={
34
- 'Repository': package_url,
35
- },
36
- python_requires=package_python_requires,
37
- )