Skip to main content

Exception Hierarchy

All SDK exceptions inherit from MemoryAPIError:
MemoryAPIError (base)
├── AuthorizationError   (401, 403)
├── PolicyDeniedError    (403)
├── NotFoundError        (404)
└── RateLimitError       (429)

Usage

from nined.memory import MemoryClient, PolicyDeniedError, RateLimitError

client = MemoryClient(base_url="https://api.9dlabs.xyz", api_key="your-key")

try:
    pack = client.context_pack(query="...", workspace_id="ws-1")
except PolicyDeniedError as e:
    print(f"Policy violation: {e.detail}")
except RateLimitError:
    print("Rate limit exceeded — back off and retry")

Exception Reference

ExceptionHTTP StatusWhen Raised
MemoryAPIErrorAnyBase class for all API errors. Catch this for generic error handling.
AuthorizationError401, 403Missing or invalid API key.
PolicyDeniedError403The request’s policy denied access to the requested data.
NotFoundError404The requested resource (artifact, receipt, workspace) does not exist.
RateLimitError429Rate limit exceeded for the current plan tier.

Exception Properties

All exceptions expose:
PropertyTypeDescription
status_codeintHTTP status code
detailstrHuman-readable error message

Handling Abstention

Abstention is not an error — it is a normal response when evidence is insufficient. Check abstain_flag instead of catching exceptions:
pack = client.context_pack(query="...", workspace_id="ws-1")

if pack["abstain_flag"]:
    # Insufficient evidence — handle gracefully
    print(f"Cannot answer: {pack['abstain_reason']}")
else:
    # Use the context
    print(pack["context_text"])