Skip to content

Exceptions API Reference#

Custom exceptions for the OpenIntent SDK.

Base Exceptions#

OpenIntentError #

OpenIntentError(message: str, status_code: Optional[int] = None, response: Optional[dict[str, Any]] = None)

Bases: Exception

Base exception for all OpenIntent SDK errors.

APIError #

APIError(message: str, status_code: Optional[int] = None, response: Optional[dict[str, Any]] = None)

Bases: OpenIntentError

Raised when an API request fails with an unexpected error.

HTTP Errors#

NotFoundError #

NotFoundError(message: str, status_code: Optional[int] = None, response: Optional[dict[str, Any]] = None)

Bases: OpenIntentError

Raised when a requested resource is not found.

ConflictError #

ConflictError(message: str, current_version: Optional[int] = None, **kwargs: Any)

Bases: OpenIntentError

Raised when there's a version conflict during optimistic concurrency control.

ValidationError #

ValidationError(message: str, errors: Optional[list[Any]] = None, **kwargs: Any)

Bases: OpenIntentError

Raised when request validation fails.

AuthenticationError #

AuthenticationError(message: str, status_code: Optional[int] = None, response: Optional[dict[str, Any]] = None)

Bases: OpenIntentError

Raised when authentication fails or API key is invalid.

Usage#

from openintent import OpenIntentClient
from openintent.exceptions import ConflictError, NotFoundError

client = OpenIntentClient(base_url="...", agent_id="...")

try:
    client.patch_state(intent_id, {"key": "value"})
except ConflictError:
    # Version mismatch - need to refresh and retry
    intent = client.get_intent(intent_id)
    client.patch_state(intent_id, {"key": "value"})
except NotFoundError:
    # Intent doesn't exist
    print("Intent not found")