Class: AerospikeError

AerospikeError

Error raised by the client when execution of a database command fails. This may be either due to an error status code returned by the server, or caused by an error condition that occured on the client side.


new AerospikeError()

Source:
Example

Expected output: "Error: 127.0.0.1:3000 Record does not exist in database. May be returned by read, or write with policy Aerospike.policy.exists.UPDATE [2]"

const Aerospike = require('aerospike')
let key = new Aerospike.Key('test', 'key', 'does_not_exist')
Aerospike.connect()
  .then(client => {
    client.get(key)
      .then(record => console.info(record))
      .catch(error => console.error(`Error: ${error.message} [${error.code}]`))
      .then(() => client.close())
  })

Extends

  • Error

Members


<readonly, nullable> client :Client

The Client instance associated with this error, if any.

Type:
Since:
  • v3.7.0
Source:
Example

Closing the client connection, when an error occurs:

const Aerospike = require('aerospike')

Aerospike.connect().then(async client => {
  await client.put(new Aerospike.Key('demo', 'test', 'foo'), { 'foo': 'bar' })
  client.close()
}).catch(error => {
  console.error('Error: %s [%i]', error.message, error.code)
  if (error.client) error.client.close()
})

<readonly> code :number

Numeric status code returned by the server or the client.

Type:
  • number
Source:
See:

<readonly, nullable> command :Command

Command during which the error occurred.

Type:
Source:

<readonly, nullable> file :string

File name of the C/C++ source file in which the error occurred.

Type:
  • string
Source:

<readonly, nullable> func :string

C/C++ function name in which the error occurred.

Type:
  • string
Source:

<readonly> inDoubt :boolean

It is possible that a write transaction completed even though the client returned this error. This may be the case when a client error occurs (like timeout) after the command was sent to the server.

Type:
  • boolean
Source:

<readonly, nullable> line :number

Line number in the C/C++ source file in which the error occurred.

Type:
  • number
Source:

Methods


isServerError()

Indicates whether the error originated on the database server.

Source:
Returns:
  • true if the server raised the error, false otherwise.
Type
boolean