Skip to content

Exceptions

All exceptions raised by the IVCAP Client SDK. Import them from ivcap_client.exception.

Quick Reference

from ivcap_client.exception import (
    IvcapError,               # base class
    IvcapApiError,            # HTTP errors (.status_code, .operation)
    NotAuthorizedException,   # 401/403
    ResourceNotFound,         # 404
    AmbiguousRequest,         # multiple matches for get_service_by_name
    MissingParameterValue,    # missing required parameter
)

Hierarchy

Exception
├── IvcapError
│   └── IvcapApiError
│       ├── NotAuthorizedException
│       └── HttpException            (backward-compat alias)
├── ResourceNotFound
├── AmbiguousRequest
└── MissingParameterValue

Note

ResourceNotFound, AmbiguousRequest, and MissingParameterValue inherit directly from the built-in Exception, not from IvcapError. Catch IvcapError to handle HTTP/API errors only; use individual exception types (or the base Exception) when you also need to catch these.

Exception Documentation

exception

IvcapError

Bases: Exception

Base class for all IVCAP client exceptions.

Source code in ivcap_client/exception.py
class IvcapError(Exception):
    """Base class for all IVCAP client exceptions."""

IvcapApiError dataclass

Bases: IvcapError

Represents an HTTP error returned by the IVCAP API.

This exception is intended to be raised by the core convenience layer. The generated ivcap_client.api.* functions may raise ivcap_client.errors.UnexpectedStatus instead.

Source code in ivcap_client/exception.py
@dataclass
class IvcapApiError(IvcapError):
    """Represents an HTTP error returned by the IVCAP API.

    This exception is intended to be raised by the *core* convenience layer.
    The generated `ivcap_client.api.*` functions may raise
    `ivcap_client.errors.UnexpectedStatus` instead.
    """

    operation: str
    status_code: int
    content: Any = None
    url: str | None = None
    headers: Mapping[str, Any] | None = None

    def __str__(self) -> str:
        parts = [f"{self.operation} failed with HTTP {self.status_code}"]
        if self.url:
            parts.append(f"url={self.url}")

        msg = " (" + ", ".join(parts[1:]) + ")" if len(parts) > 1 else ""
        body = _safe_decode_content(self.content)
        if body:
            return f"{parts[0]}{msg}: {body}"
        return f"{parts[0]}{msg}"

NotAuthorizedException

Bases: IvcapApiError

Raised when the request is not authorized (typically HTTP 401/403).

Source code in ivcap_client/exception.py
class NotAuthorizedException(IvcapApiError):
    """Raised when the request is not authorized (typically HTTP 401/403)."""

    def __init__(
        self,
        operation: str,
        status_code: int = 401,
        content: Any = None,
        url: str | None = None,
        headers: Mapping[str, Any] | None = None,
    ):
        super().__init__(
            operation=operation,
            status_code=status_code,
            content=content,
            url=url,
            headers=headers,
        )

ResourceNotFound

Bases: Exception

Exception raised when requestred resource is not found.

Attributes:

Name Type Description
resource

name or URN of missing resource

Source code in ivcap_client/exception.py
class ResourceNotFound(Exception):
    """Exception raised when requestred resource is not found.

    Attributes:
        resource: name or URN of missing resource
    """

    def __init__(self, resource: str):
        self.resource = resource
        self.message = f"resource '{resource}' not found"
        super().__init__(self.message)

AmbiguousRequest

Bases: Exception

Exception raised when request is not specific enough.

Attributes:

Name Type Description
message

cause for ambiguity

Source code in ivcap_client/exception.py
class AmbiguousRequest(Exception):
    """Exception raised when request is not specific enough.

    Attributes:
        message: cause for ambiguity
    """

    def __init__(self, message: str):
        super().__init__(message)

HttpException dataclass

Bases: IvcapApiError

Backward compatible alias for :class:IvcapHttpError.

Source code in ivcap_client/exception.py
class HttpException(IvcapApiError):
    """Backward compatible alias for :class:`IvcapHttpError`."""