본문으로 건너뛰기
버전: In Development

Exceptions

모든 예외는 aerospikeaerospike.exception에서 사용할 수 있습니다.

import aerospike_py as aerospike
from aerospike_py.exception import RecordNotFound

Exception 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

Base Exceptions

Exception설명
AerospikeError모든 Aerospike 예외의 기본 클래스
ClientError클라이언트 측 오류 (연결, 설정)
ClusterError클러스터 연결/탐색 오류
InvalidArgError메서드에 잘못된 인수가 전달됨
AerospikeTimeoutError작업 시간 초과 (alias: TimeoutError, deprecated)
ServerError서버 측 오류
RecordError레코드 수준 작업 오류

Record Exceptions

Exception설명
RecordNotFound레코드가 존재하지 않음
RecordExistsError레코드가 이미 존재함 (CREATE_ONLY 정책)
RecordGenerationError세대 불일치 (Optimistic Locking)
RecordTooBig레코드가 크기 제한을 초과함
BinNameError잘못된 빈 이름 (너무 길거나 유효하지 않은 문자)
BinExistsError빈이 이미 존재함
BinNotFound빈이 존재하지 않음
BinTypeError빈 타입 불일치
FilteredOutExpression에 의해 레코드가 필터링됨

Server Exceptions

Exception설명
AerospikeIndexErrorSecondary Index 작업 오류 (alias: IndexError, deprecated)
IndexNotFound인덱스가 존재하지 않음
IndexFoundError인덱스가 이미 존재함
QueryError쿼리 실행 오류
QueryAbortedError쿼리가 중단됨
AdminError관리 작업 오류
UDFErrorUDF 등록/실행 오류

Error Handling Examples

Basic Error Handling

import aerospike_py as aerospike
from aerospike_py.exception import RecordNotFound, AerospikeError

try:
_, meta, bins = client.get(("test", "demo", "nonexistent"))
except RecordNotFound:
print("Record not found")
except AerospikeError as e:
print(f"Aerospike error: {e}")

Optimistic Locking

from aerospike_py.exception import RecordGenerationError

try:
_, meta, bins = client.get(key)
client.put(key, {"val": bins["val"] + 1},
meta={"gen": meta.gen},
policy={"gen": aerospike.POLICY_GEN_EQ})
except RecordGenerationError:
print("Record was modified by another client")

Create Only

from aerospike_py.exception import RecordExistsError

try:
client.put(key, bins, policy={"exists": aerospike.POLICY_EXISTS_CREATE_ONLY})
except RecordExistsError:
print("Record already exists")

Connection Errors

from aerospike_py.exception import ClientError, ClusterError, AerospikeTimeoutError

try:
client = aerospike.client(config).connect()
except ClusterError:
print("Cannot connect to cluster")
except AerospikeTimeoutError:
print("Connection timed out")
except ClientError as e:
print(f"Client error: {e}")