Error Strategy

Error handling strategy for SDK operations.

Controls how per-record errors are surfaced during execution:

  • Default (no argument): single-key operations raise immediately; batch / multi-key operations embed errors in the RecordStream.

  • ErrorStrategy.IN_STREAM: always embed errors as RecordResult entries with non-OK result codes, even for single-key operations.

  • ErrorHandler callback: errors are dispatched to the callback and excluded from the returned stream.

class aerospike_sdk.error_strategy.ErrorStrategy[source]

Bases: Enum

Strategy for handling per-record errors during execution.

Pass to execute(on_error=...) to override the default behavior.

Example:

stream = await (
    session.query(k1, k2).execute(on_error=ErrorStrategy.IN_STREAM)
)
IN_STREAM = 'in_stream'

Embed errors in the RecordStream as RecordResult entries.

aerospike_sdk.error_strategy.ErrorHandler

Callback (key, index, exception) -> None for per-record error handling.

The callback receives the failed record’s key, its position in the batch (0-based; 0 for single-key, -1 for queries), and the typed exception. Errors dispatched to the handler are excluded from the returned stream.

alias of Callable[[Key, int, AerospikeError], None]

aerospike_sdk.error_strategy.OnError

Type alias for the on_error parameter of execute().

alias of ErrorStrategy | Callable[[Key, int, AerospikeError], None]