Skip to content

Exceptions

opake.exceptions provides stable semantic categories for handling failures from public Opake APIs:

from opake.exceptions import CalibrationError, CheckpointError, ConfigurationError

try:
    result = calibrate(...)
except CalibrationError:
    # Use different search bounds or inspect the process definition.
    ...
except ConfigurationError:
    # Correct an invalid or incompatible user option.
    ...
except CheckpointError:
    # Do not resume until the complete DP checkpoint is available.
    ...
Exception Common error family Use it for
OpakeError Exception Handling any semantic Opake failure.
ConfigurationError ValueError Invalid values, incompatible options, and unsupported user configuration.
CalibrationError ConfigurationError Invalid or unsatisfied privacy-calibration searches.
PrivacyBudgetError ConfigurationError Invalid privacy-budget definitions.
InputTypeError TypeError Arguments whose Python type cannot satisfy an Opake API contract.
OperationError RuntimeError An Opake operation that cannot complete in its current state.
CheckpointError OperationError Saving, restoring, or resuming an incompatible or incomplete Opake checkpoint.

Standard Python and third-party errors still surface when they are more specific, such as an I/O failure while opening a caller-provided path.

exceptions

Public semantic exception taxonomy for Opake.

Import these types when application code needs to handle stable categories of Opake failures. They preserve familiar Python error relationships: configuration, calibration, and privacy-budget errors are ValueError subclasses, while checkpoint failures are RuntimeError subclasses.

CalibrationError

Bases: ConfigurationError

Raised when privacy calibration cannot validate or satisfy its search.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class CalibrationError(ConfigurationError):
    """Raised when privacy calibration cannot validate or satisfy its search."""

CheckpointError

Bases: OperationError

Raised when an Opake checkpoint cannot be saved, restored, or resumed.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class CheckpointError(OperationError):
    """Raised when an Opake checkpoint cannot be saved, restored, or resumed."""

ConfigurationError

Bases: OpakeError, ValueError

Raised when an Opake API receives invalid or incompatible configuration.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class ConfigurationError(OpakeError, ValueError):
    """Raised when an Opake API receives invalid or incompatible configuration."""

InputTypeError

Bases: OpakeError, TypeError

Raised when an Opake API receives an argument of an invalid type.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class InputTypeError(OpakeError, TypeError):
    """Raised when an Opake API receives an argument of an invalid type."""

OpakeError

Bases: Exception

Base class for failures reported by Opake public APIs.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class OpakeError(Exception):
    """Base class for failures reported by Opake public APIs."""

    @classmethod
    def raise_(
        cls,
        message: str,
        *,
        cause: BaseException | None = None,
        suppress_context: bool = False,
    ) -> NoReturn:
        """Raise this category with a diagnostic message."""
        if suppress_context:
            raise cls(message) from None
        if cause is not None:
            raise cls(message) from cause
        raise cls(message)

raise_(message, *, cause=None, suppress_context=False) classmethod

Raise this category with a diagnostic message.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
@classmethod
def raise_(
    cls,
    message: str,
    *,
    cause: BaseException | None = None,
    suppress_context: bool = False,
) -> NoReturn:
    """Raise this category with a diagnostic message."""
    if suppress_context:
        raise cls(message) from None
    if cause is not None:
        raise cls(message) from cause
    raise cls(message)

OperationError

Bases: OpakeError, RuntimeError

Raised when an Opake operation cannot complete its requested work.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class OperationError(OpakeError, RuntimeError):
    """Raised when an Opake operation cannot complete its requested work."""

PrivacyBudgetError

Bases: ConfigurationError

Raised when a privacy-budget definition or operation is invalid.

Source code in packages/opake-base/src/opake/api/base/exceptions/__init__.py
class PrivacyBudgetError(ConfigurationError):
    """Raised when a privacy-budget definition or operation is invalid."""