python-infrastructure-exceptions
Infrastructure layer exception classes for Python applications.
Purpose: Low-level infrastructure errors (database, network, external services).
Separation:
python-infrastructure-exceptions= Infrastructure layer (DB, network, cache, queue)python-app-exceptions= Business/application layer (validation, business rules)
Installation
pip install python-infrastructure-exceptions
Usage
from python_infrastructure_exceptions import (
InfrastructureException,
DatabaseError,
ExternalServiceError,
ConfigurationError,
CacheError,
MessageQueueError
)
# Database errors
raise DatabaseError("Connection pool exhausted", details="Max connections: 20")
# External service errors
raise ExternalServiceError("Stripe API timeout", service_name="stripe")
# Configuration errors
raise ConfigurationError("Missing DATABASE_URL environment variable")
# Cache errors
raise CacheError("Redis connection failed", details="Connection refused")
# Message queue errors
raise MessageQueueError("Kafka broker unavailable", details="broker.example.com:9092")
Exception Hierarchy
InfrastructureException (base)
├── DatabaseError # Database connection, query failures
├── ExternalServiceError # Third-party API failures
├── ConfigurationError # Missing/invalid configuration
├── CacheError # Redis, Memcached failures
└── MessageQueueError # Kafka, RabbitMQ failures
When to Use
| Exception Type | Use For | Example |
|---|---|---|
| InfrastructureException | Base class for custom infrastructure errors | Custom database adapter error |
| DatabaseError | Database connection, query, transaction failures | PostgreSQL connection pool exhausted |
| ExternalServiceError | Third-party API failures | Stripe API timeout, SendGrid error |
| ConfigurationError | Missing or invalid configuration | Missing DATABASE_URL env var |
| CacheError | Cache layer failures | Redis connection refused |
| MessageQueueError | Message broker failures | Kafka broker unavailable |
Comparison with python-app-exceptions
| Layer | Library | Exceptions | Example |
|---|---|---|---|
| Infrastructure | python-infrastructure-exceptions |
DatabaseError, ExternalServiceError | PostgreSQL timeout |
| Business | python-app-exceptions |
ValidationError, BusinessRuleViolation | Invalid email format |
Features
- ✅ Infrastructure-specific error types
- ✅ Detailed error context (service name, connection details)
- ✅ Framework-agnostic
- ✅ Zero dependencies
- ✅ Type-safe error handling
License
MIT
Metadata
Release files for python-infrastructure-exceptions 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_infrastructure_exceptions-0.1.0.tar.gz | 5.6 kB | Without provenance | Details for python_infrastructure_exceptions-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_infrastructure_exceptions-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for python_infrastructure_exceptions-0.1.0-py3-none-any.whl |
Total release size: 12.5 kB
Release files / python_infrastructure_exceptions-0.1.0.tar.gz
| Download URL | python_infrastructure_exceptions-0.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da39abed0586eff27ec35c304b944a904b24a29caa428e64687f05fc42a75394
|
|
BLAKE2b-256 checksum How to use checksums |
43dfbf8aa0fbb330a860bdd59b6df6019aca048977e3373bcaffda06a196a11d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Release files / python_infrastructure_exceptions-0.1.0-py3-none-any.whl
| Download URL | python_infrastructure_exceptions-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
580e5dd07f0a318a0f0312fccc5c31a5ca912792d5dcb8977a3181aaf1fdef23
|
|
BLAKE2b-256 checksum How to use checksums |
b3854d426acd00b40ee0abc30827c18f0bb99900ce3018209224d38faff7cf99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Security for python-infrastructure-exceptions 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.