Exceptions¶
Every failure in the package raises a subclass of CryptographyManagerError,
which the workflow maps onto a status and an HTTP code. The one exception is
BackendImportError, raised when an optional backend is unavailable.
exceptions
¶
Custom exceptions for the Cryptography Manager.
This module defines all custom exceptions used throughout the library, providing clear error handling and debugging information.
BackendImportError
¶
Bases: Exception
Raised when an optional cryptographic backend cannot be imported.
Deliberately not named ImportError: shadowing the builtin makes
except ImportError inside this package silently stop catching real
import failures.
CryptographyManagerError
¶
Bases: Exception
Base exception for all Cryptography Manager errors.
Initialize the base exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
OperationNotImplementedError
¶
OperationNotImplementedError(
message: str,
operation: str | None = None,
error_code: str | None = None,
)
Bases: CryptographyManagerError
Raised for a recognised operation that has no adapter yet.
Distinct from an unknown operation: the request was well-formed and names something the component intends to support, so the caller should be told "not yet" rather than "no such thing".
Initialize the not-implemented error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
operation
|
str | None
|
The operation that is not yet available |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
ConfigurationError
¶
Bases: CryptographyManagerError
Raised when there are configuration-related errors.
Initialize configuration error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
config_key
|
str | None
|
The configuration key that caused the error |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
AdapterError
¶
AdapterError(
message: str,
adapter_name: str | None = None,
operation: str | None = None,
error_code: str | None = None,
)
Bases: CryptographyManagerError
Raised when there are adapter-related errors.
Initialize adapter error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
adapter_name
|
str | None
|
Name of the adapter that caused the error |
None
|
operation
|
str | None
|
The operation that failed |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
KeyManagementError
¶
KeyManagementError(
message: str,
key_id: str | None = None,
operation: str | None = None,
error_code: str | None = None,
)
Bases: CryptographyManagerError
Raised when there are key management-related errors.
Initialize key management error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
key_id
|
str | None
|
ID of the key that caused the error |
None
|
operation
|
str | None
|
The key operation that failed |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
AuditError
¶
Bases: CryptographyManagerError
Raised when there are audit logging-related errors.
Initialize audit error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
operation
|
str | None
|
The operation that failed to be audited |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
HomomorphicEncryptionError
¶
HomomorphicEncryptionError(
message: str,
scheme: str | None = None,
operation: str | None = None,
error_code: str | None = None,
)
Bases: AdapterError
Raised when there are homomorphic encryption-related errors.
Initialize homomorphic encryption error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
scheme
|
str | None
|
The HE scheme that caused the error |
None
|
operation
|
str | None
|
The HE operation that failed |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
SecureMultiPartyComputationError
¶
SecureMultiPartyComputationError(
message: str,
protocol: str | None = None,
operation: str | None = None,
error_code: str | None = None,
)
Bases: AdapterError
Raised when there are secure multi-party computation-related errors.
Initialize SMPC error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
protocol
|
str | None
|
The SMPC protocol that caused the error |
None
|
operation
|
str | None
|
The SMPC operation that failed |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
DifferentialPrivacyError
¶
DifferentialPrivacyError(
message: str,
mechanism: str | None = None,
operation: str | None = None,
error_code: str | None = None,
)
Bases: AdapterError
Raised when there are differential privacy-related errors.
Initialize differential privacy error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
mechanism
|
str | None
|
The DP mechanism that caused the error |
None
|
operation
|
str | None
|
The DP operation that failed |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|
Source code in src/cryptography_manager/exceptions.py
StandardCryptographyError
¶
StandardCryptographyError(
message: str,
algorithm: str | None = None,
operation: str | None = None,
error_code: str | None = None,
)
Bases: AdapterError
Raised when there are standard cryptography-related errors.
Initialize standard cryptography error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error message |
required |
algorithm
|
str | None
|
The cryptographic algorithm that caused the error |
None
|
operation
|
str | None
|
The crypto operation that failed |
None
|
error_code
|
str | None
|
Optional error code for programmatic handling |
None
|