Skip to content

client.errors

crp.sdk.proxies_more._ErrorsProxy

Public CRP exception taxonomy proxy (§6.8).

Exposes common exception classes and a lookup helper.

Source code in crp/sdk/proxies_more.py
class _ErrorsProxy:
    """Public CRP exception taxonomy proxy (§6.8).

    Exposes common exception classes and a lookup helper.
    """

    def __init__(self, orchestrator: Any) -> None:
        self._orchestrator = orchestrator

    def _module(self) -> Any:
        from crp.core import errors as errors_mod

        return errors_mod

    def exception(self, name: str) -> Any:
        """Return a CRP exception class by name.

        Args:
            name: Exception class name (e.g. ``"CRPError"``).

        Returns:
            Exception class, or ``CRPError`` if ``name`` is unknown.
        """
        mod = self._module()
        return getattr(mod, name, mod.CRPError)

    def all_exceptions(self) -> dict[str, Any]:
        """Return a mapping of all public CRP exception class names to classes.

        Returns:
            Dict of exception name to exception class.
        """
        mod = self._module()
        return {
            name: obj
            for name, obj in vars(mod).items()
            if isinstance(obj, type) and issubclass(obj, Exception) and not name.startswith("_")
        }

    @property
    def CRPError(self) -> Any:
        """Base CRP exception class."""
        return self._module().CRPError

    @property
    def ConfigError(self) -> Any:
        """Configuration-related error (mapped to ``ValidationError``)."""
        return self._module().ValidationError

    @property
    def SafetyViolation(self) -> Any:
        """Safety violation error (mapped to ``SecurityInvariantError``)."""
        return self._module().SecurityInvariantError

    @property
    def ValidationError(self) -> Any:
        """Validation error class."""
        return self._module().ValidationError

    @property
    def SecurityInvariantError(self) -> Any:
        """Security invariant error class."""
        return self._module().SecurityInvariantError

    @property
    def BudgetExhaustedError(self) -> Any:
        """Budget exhausted error class."""
        return self._module().BudgetExhaustedError

    @property
    def ProviderError(self) -> Any:
        """Provider error class."""
        return self._module().ProviderError

CRPError property

Base CRP exception class.

ConfigError property

Configuration-related error (mapped to ValidationError).

SafetyViolation property

Safety violation error (mapped to SecurityInvariantError).

ValidationError property

Validation error class.

SecurityInvariantError property

Security invariant error class.

BudgetExhaustedError property

Budget exhausted error class.

ProviderError property

Provider error class.

exception(name)

Return a CRP exception class by name.

Parameters:

Name Type Description Default
name str

Exception class name (e.g. "CRPError").

required

Returns:

Type Description
Any

Exception class, or CRPError if name is unknown.

Source code in crp/sdk/proxies_more.py
def exception(self, name: str) -> Any:
    """Return a CRP exception class by name.

    Args:
        name: Exception class name (e.g. ``"CRPError"``).

    Returns:
        Exception class, or ``CRPError`` if ``name`` is unknown.
    """
    mod = self._module()
    return getattr(mod, name, mod.CRPError)

all_exceptions()

Return a mapping of all public CRP exception class names to classes.

Returns:

Type Description
dict[str, Any]

Dict of exception name to exception class.

Source code in crp/sdk/proxies_more.py
def all_exceptions(self) -> dict[str, Any]:
    """Return a mapping of all public CRP exception class names to classes.

    Returns:
        Dict of exception name to exception class.
    """
    mod = self._module()
    return {
        name: obj
        for name, obj in vars(mod).items()
        if isinstance(obj, type) and issubclass(obj, Exception) and not name.startswith("_")
    }