Skip to main content

Error handling


The java client can throw the following runtime exceptions:

ExceptionDescription
AerospikeExceptionBase exception. A more specific error code can be obtained by getResultCode(). View Result Codes
AerospikeException.TimeoutCommand has timed out.
AerospikeException.SerializeError using java or messagepack encoding/decoding.
AerospikeException.ParseError parsing server response.
AerospikeException.ConnectionError establishing connection to server node.
AerospikeException.InvalidNodeThe chosen node is not active or a namespace is removed while the client is 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("192.168.1.150", 3000);

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