Exception module for reuse along projects.
Project description
Darca Exception is a powerful and feature-rich Python exception base class designed to enhance error handling in your projects. It integrates seamlessly with darca-log-facility for structured logging, making debugging and error tracking effortless.
🚀 Key Features
Generic & Reusable - Works across various projects without modification.
Structured Logging - Uses DarcaLogger for clean and consistent logs.
Exception Chaining - Captures underlying causes (cause).
Metadata Support - Add extra details (metadata).
JSON Serialization - Easily convert exceptions to structured JSON.
100% Test Coverage - Ensured via pytest and pytest-cov.
—
📦 Installation
Darca Exception uses Poetry for dependency management. To install dependencies, use:
make install
This will: - Create a virtual environment (venv) if needed. - Install Poetry and project dependencies.
—
🚀 Usage
### Raising an Exception You can raise an exception using DarcaException:
from darca_exception import DarcaException
raise DarcaException("Something went wrong", error_code="GENERIC_ERROR")
### Exception Chaining You can chain exceptions using cause:
try:
1 / 0
except ZeroDivisionError as e:
raise DarcaException("Math error", error_code="MATH_001", cause=e)
### Structured JSON Output Converting an exception to JSON is simple:
try:
raise DarcaException("Database failure", error_code="DB_FAIL")
except DarcaException as e:
print(e.to_dict())
—
🛠 Development & Testing
### Running Tests To run the test suite and check coverage:
make test
This will: - Run pytest with coverage enabled. - Generate a test coverage report.
### Formatting & Linting To automatically format and check code consistency:
make format
### Checking Before Pushing Before pushing code, always run:
make check
This will: - Format the code. - Run pre-commit hooks. - Execute tests.
—
📖 Building Documentation
To generate documentation using Sphinx:
make docs
This will: - Build the documentation in docs/build/html/.
—
🚀 Pre-Commit Hooks
To run pre-commit checks before committing code:
make precommit
This will: - Run linting, formatting, and static analysis. - Prevent common mistakes before pushing code.
—
🔧 Adding Dependencies
You can dynamically add dependencies using make:
Development dependencies (dev group):
make add-deps group=dev deps="pytest black isort"Production dependencies:
make add-prod-deps deps="requests pydantic"
—
🗑 Cleaning Up
To remove the virtual environment and reset dependencies:
make clean
This will: - Remove the Poetry environment. - Delete cache files.
—
💡 Contributing
Contributions are welcome! You can contribute by:
Submitting feature requests
Reporting issues
Creating pull requests for fixes and enhancements
Before submitting a pull request, make sure to:
Run make check to ensure all checks pass.
Follow code style and formatting guidelines.
—
📜 License
This project is licensed under the MIT License. See LICENSE for details.
—
🎉 Final Notes
This project is production-ready and fully tested. 🚀 If you find any issues, feel free to submit a bug report!
—
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file darca_exception-0.1.1.tar.gz.
File metadata
- Download URL: darca_exception-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c6a4d81c3c25af31c49ca9e3bc7a0a90039e87d1237f65daf9295abb60ab8a6
|
|
| MD5 |
e21c323b25033edd94aa1f29de9a527e
|
|
| BLAKE2b-256 |
a309305728691bf7befcc05aba96e8112e8a6364ea1df2a52c231ee6d18499be
|
Provenance
The following attestation bundles were made for darca_exception-0.1.1.tar.gz:
Publisher:
cd.yml on roelkist/darca-exception
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
darca_exception-0.1.1.tar.gz -
Subject digest:
0c6a4d81c3c25af31c49ca9e3bc7a0a90039e87d1237f65daf9295abb60ab8a6 - Sigstore transparency entry: 226593942
- Sigstore integration time:
-
Permalink:
roelkist/darca-exception@068b77fd8a2e906f3ec9070885f513d507943fa0 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/roelkist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@068b77fd8a2e906f3ec9070885f513d507943fa0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file darca_exception-0.1.1-py3-none-any.whl.
File metadata
- Download URL: darca_exception-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f28e629a63629d0d7c5375e11add20baed8f30acb85bdd6be742800e8e7e0cf1
|
|
| MD5 |
ff3cef7e10b24d48702c264d212f529b
|
|
| BLAKE2b-256 |
f85a967ce8602615eb2aa22345cea678b98db1ae6086c7355d83e95d1500844b
|
Provenance
The following attestation bundles were made for darca_exception-0.1.1-py3-none-any.whl:
Publisher:
cd.yml on roelkist/darca-exception
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
darca_exception-0.1.1-py3-none-any.whl -
Subject digest:
f28e629a63629d0d7c5375e11add20baed8f30acb85bdd6be742800e8e7e0cf1 - Sigstore transparency entry: 226593953
- Sigstore integration time:
-
Permalink:
roelkist/darca-exception@068b77fd8a2e906f3ec9070885f513d507943fa0 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/roelkist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@068b77fd8a2e906f3ec9070885f513d507943fa0 -
Trigger Event:
release
-
Statement type: