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.

Constructor

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')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
  // Timeouts disabled, latency dependent on server location. Configure as needed.
  policies: {
    read : new Aerospike.ReadPolicy({socketTimeout : 0, totalTimeout : 0}),
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0})
  }
}

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

(nullable) client :Client

Description:
  • The Client instance associated with this error, if any.

Source:
Since:
  • v3.7.0

The Client instance associated with this error, if any.

Type:
Example

Closing the client connection, when an error occurs:

const Aerospike = require('aerospike')

// INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
var config = {
  hosts: '192.168.33.10:3000',
  // Timeouts disabled, latency dependent on server location. Configure as needed.
  policies: {
    read : new Aerospike.ReadPolicy({socketTimeout : 0, totalTimeout : 0}),
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0})
  }
}

Aerospike.connect(config).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()
})

code :number

Description:
  • Numeric status code returned by the server or the client.

Source:
See:

Numeric status code returned by the server or the client.

Type:
  • number

(nullable) command :Object

Description:
  • Command during which the error occurred.

Source:

Command during which the error occurred.

Type:
  • Object

(nullable) file :string

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

Source:

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

Type:
  • string

(nullable) func :string

Description:
  • C/C++ function name in which the error occurred.

Source:

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

Type:
  • string

inDoubt :boolean

Description:
  • 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.

Source:

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

(nullable) line :number

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

Source:

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

Type:
  • number

Methods

isServerError() → {boolean}

Description:
  • Indicates whether the error originated on the database server.

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