infrastructure.errors.infrastructure_error¶
src.infrastructure.errors.infrastructure_error
¶
Infrastructure layer error types.
Infrastructure errors represent failures in external systems (database, cache, providers).
Architecture: - Infrastructure catches exceptions and maps to DomainError - Infrastructure errors inherit from DomainError (not Exception) - Uses InfrastructureErrorCode for internal error tracking - Maps to domain ErrorCode when flowing to domain layer - Used with Result types for error propagation
Classes¶
InfrastructureError
dataclass
¶
Bases: DomainError
Base infrastructure error.
Infrastructure errors still use domain ErrorCode enum (not InfrastructureErrorCode). The InfrastructureErrorCode is for internal infrastructure tracking only.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
ErrorCode
|
Domain ErrorCode (maps from InfrastructureErrorCode). |
message |
str
|
Human-readable message. |
infrastructure_code |
InfrastructureErrorCode | None
|
Original infrastructure error code. |
details |
dict[str, Any] | None
|
Additional context. |
Source code in src/infrastructure/errors/infrastructure_error.py
DatabaseError
dataclass
¶
Bases: InfrastructureError
Database-specific errors.
Wraps SQLAlchemy exceptions and provides consistent error handling.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
ErrorCode
|
Domain ErrorCode. |
message |
str
|
Human-readable message. |
infrastructure_code |
InfrastructureErrorCode | None
|
Database-specific error code. |
details |
dict[str, Any] | None
|
Additional context (constraint name, original error). |
Source code in src/infrastructure/errors/infrastructure_error.py
CacheError
dataclass
¶
Bases: InfrastructureError
Cache-specific errors.
Wraps Redis/cache exceptions and provides consistent error handling.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
ErrorCode
|
Domain ErrorCode. |
message |
str
|
Human-readable message. |
infrastructure_code |
InfrastructureErrorCode | None
|
Cache-specific error code. |
details |
dict[str, Any] | None
|
Additional context (key, operation, original error). |
Source code in src/infrastructure/errors/infrastructure_error.py
ExternalServiceError
dataclass
¶
Bases: InfrastructureError
External service integration errors.
Used for non-provider external services like email, SMS, payment gateways.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
ErrorCode
|
Domain ErrorCode. |
message |
str
|
Human-readable message. |
infrastructure_code |
InfrastructureErrorCode | None
|
Service-specific error code. |
service_name |
str
|
Name of the external service. |
details |
dict[str, Any] | None
|
Additional context (status code, response). |