Skip to main content

Darca Exception - Advanced Exception Handling

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:

  1. Run make check to ensure all checks pass.

  2. 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!

Release files for darca-exception 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for darca-exception 0.1.1
File Size Uploaded
darca_exception-0.1.1.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for darca-exception 0.1.1
File Interpreter ABI Platform
darca_exception-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / darca_exception-0.1.1.tar.gz

Download URL darca_exception-0.1.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0c6a4d81c3c25af31c49ca9e3bc7a0a90039e87d1237f65daf9295abb60ab8a6
BLAKE2b-256 checksum
How to use checksums
a309305728691bf7befcc05aba96e8112e8a6364ea1df2a52c231ee6d18499be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2025.

Transparency log

Release files / darca_exception-0.1.1-py3-none-any.whl

Download URL darca_exception-0.1.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f28e629a63629d0d7c5375e11add20baed8f30acb85bdd6be742800e8e7e0cf1
BLAKE2b-256 checksum
How to use checksums
f85a967ce8602615eb2aa22345cea678b98db1ae6086c7355d83e95d1500844b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page