Skip to main content

Error Handling

The java client can throw the following runtime exceptions:

AerospikeExceptionBase exception. A more specific error code can be obtained by getResultCode(). View Result Codes
AerospikeException.TimeoutTransaction has timed out.
AerospikeException.SerializeError using java or messagepack encoding/decoding.
AerospikeException.ParseError parsing server response.
AerospikeException.ConnectionError establishing connection to server node.
AerospikeException.InvalidNodeError when chosen node is not active.
AerospikeException.ScanTerminatedScan was terminated prematurely.
AerospikeException.QueryTerminatedQuery was terminated prematurely.
AerospikeException.CommandRejectedAsync command was rejected because the maximum concurrent database commands have been exceeded.

Here is example code that handles an AerospikeException.

AerospikeClient client = new AerospikeClient("", 3000);

try {
try {
client.put(null, new Key("test", "demo", "key"), new Bin("testbin", 32));
catch (AerospikeException.Timeout aet) {
// Handle timeouts differently.
catch (AerospikeException ae) {
throw new MyException("AerospikeException " + ae.getResultCode() + ": " + ae.getMessage());
finally {