Exceptions#

The exceptions that CyteType defines all derive from CyteTypeError. Errors that the server reports derive from APIError: the class tells you what went wrong, and error_code holds the server’s error code. NetworkError means that the server could not be reached or answered unexpectedly, and CyteTypeTimeoutError that a request or the wait for a job took too long. Import them from cytetype:

from cytetype import CyteTypeError, QuotaExceededError

try:
    adata = annotator.run(study_context="Human PBMCs from a healthy donor.")
except QuotaExceededError as error:
    print(error.error_code, error.message)

CyteTypeTimeoutError is the client’s own TimeoutError class from cytetype.api.exceptions. The package exports it under this name so that from cytetype import * does not hide Python’s built-in TimeoutError. cytetype.api exports the class as CyteTypeTimeoutError and, as in earlier releases, as TimeoutError, so from cytetype.api import * does hide the built-in class. Errors and error codes explains what to do about each error.

exception cytetype.CyteTypeError(message, error_code=None)#

Bases: Exception

Base exception for all CyteType errors.

message: str#

The error message.

error_code: str | None#

The machine-readable error code, such as QUOTA_EXCEEDED, or None if the error has none.

exception cytetype.APIError(message, error_code=None)#

Bases: CyteTypeError

Base class for API-related errors.

exception cytetype.AuthenticationError(message, error_code=None)#

Bases: APIError

Authentication failed - INVALID_TOKEN, TOKEN_INACTIVE, AUTHENTICATION_REQUIRED.

exception cytetype.AuthorizationError(message, error_code=None)#

Bases: APIError

Authorization failed - ACCESS_DENIED, LICENSE_EXPIRED, VPN_BLOCKED.

exception cytetype.RateLimitError(message, error_code=None)#

Bases: APIError

Rate limit exceeded - RATE_LIMIT_EXCEEDED.

exception cytetype.QuotaExceededError(message, error_code=None)#

Bases: APIError

Quota exceeded - QUOTA_EXCEEDED.

exception cytetype.JobNotFoundError(message, error_code=None)#

Bases: APIError

Job not found - JOB_NOT_FOUND.

exception cytetype.JobFailedError(message, error_code=None)#

Bases: APIError

Job failed - JOB_FAILED.

exception cytetype.LLMValidationError(message, error_code=None)#

Bases: APIError

LLM validation failed - LLM_VALIDATION_FAILED.

exception cytetype.ClientDisconnectedError(message, error_code=None)#

Bases: APIError

Server detected client disconnection mid-request - CLIENT_DISCONNECTED (HTTP 499).

exception cytetype.NetworkError(message='Network connection failed', error_code=None)#

Bases: CyteTypeError

Network connectivity issue.

exception cytetype.CyteTypeTimeoutError(message='Request timed out', error_code=None)#

Bases: CyteTypeError

Client-side timeout waiting for results.