본문으로 건너뛰기

예외

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

Exception설명
AerospikeError모든 Aerospike exception 의 base
ClientErrorclient-side error (connection, config)
ClusterErrorcluster 연결/discovery error
InvalidArgError잘못된 인자
AerospikeTimeoutErroroperation timeout
ServerErrorserver-side error
RecordErrorrecord-level error

Record

Exception설명
RecordNotFoundrecord 없음
RecordExistsErrorrecord 이미 존재 (CREATE_ONLY)
RecordGenerationErrorgeneration mismatch (optimistic lock)
RecordTooBigrecord 가 크기 한도 초과
BinNameError잘못된 bin name
BinExistsErrorbin 이미 존재
BinNotFoundbin 없음
BinTypeErrorbin type mismatch
FilteredOutexpression filter 로 제외

Server

Exception설명
AerospikeIndexErrorsecondary index error
IndexNotFoundindex 없음
IndexFoundErrorindex 이미 존재
QueryErrorquery 실행 error
QueryAbortedErrorquery 중단됨
AdminErroradmin operation error
UDFErrorUDF error
노트

TimeoutErrorIndexError 는 Python builtin shadow 방지를 위해 각각 AerospikeTimeoutErrorAerospikeIndexError 의 deprecated alias.

예제

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

# 기본 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")

production 패턴은 Error Handling Guide 참조.