Skip to main content
Version: 0.0.3

Exceptions

from aerospike_py.exception import RecordNotFound, AerospikeError

Hierarchy

Exception
└── AerospikeError
├── ClientError
├── ClusterError
├── InvalidArgError
├── AerospikeTimeoutError
├── ServerError
│ ├── AerospikeIndexError
│ │ ├── IndexNotFound
│ │ └── IndexFoundError
│ ├── QueryError
│ │ └── QueryAbortedError
│ ├── AdminError
│ └── UDFError
└── RecordError
├── RecordNotFound
├── RecordExistsError
├── RecordGenerationError
├── RecordTooBig
├── BinNameError
├── BinExistsError
├── BinNotFound
├── BinTypeError
└── FilteredOut

Reference

Base

ExceptionDescription
AerospikeErrorBase for all Aerospike exceptions
ClientErrorClient-side errors (connection, config)
ClusterErrorCluster connection/discovery errors
InvalidArgErrorInvalid argument
AerospikeTimeoutErrorOperation timed out
ServerErrorServer-side errors
RecordErrorRecord-level errors

Record

ExceptionDescription
RecordNotFoundRecord does not exist
RecordExistsErrorRecord already exists (CREATE_ONLY)
RecordGenerationErrorGeneration mismatch (optimistic lock)
RecordTooBigRecord exceeds size limit
BinNameErrorInvalid bin name
BinExistsErrorBin already exists
BinNotFoundBin does not exist
BinTypeErrorBin type mismatch
FilteredOutExcluded by expression filter

Server

ExceptionDescription
AerospikeIndexErrorSecondary index error
IndexNotFoundIndex does not exist
IndexFoundErrorIndex already exists
QueryErrorQuery execution error
QueryAbortedErrorQuery aborted
AdminErrorAdmin operation error
UDFErrorUDF error
note

TimeoutError and IndexError are deprecated aliases for AerospikeTimeoutError and AerospikeIndexError to avoid shadowing Python builtins.

Examples

from aerospike_py.exception import (
RecordNotFound,
RecordExistsError,
RecordGenerationError,
AerospikeTimeoutError,
AerospikeError,
)

# Basic error handling
try:
record = client.get(("test", "demo", "nonexistent"))
except RecordNotFound:
print("Not found")
except AerospikeError as e:
print(f"Error: {e}")

# Optimistic locking
try:
record = client.get(key)
client.put(
key,
{"val": record.bins["val"] + 1},
meta={"gen": record.meta.gen},
policy={"gen": aerospike.POLICY_GEN_EQ},
)
except RecordGenerationError:
print("Concurrent modification detected")

# Create-only
try:
client.put(key, bins, policy={"exists": aerospike.POLICY_EXISTS_CREATE_ONLY})
except RecordExistsError:
print("Already exists")

See the Error Handling Guide for production patterns.