Loading...
Searching...
No Matches
Data Fields | Related Symbols
as_error Struct Reference

Detailed Description

All operations that interact with the Aerospike cluster accept an as_error argument and return an as_status value. The as_error argument is populated with information about the error that occurred. The as_status return value is the as_error.code value.

When an operation succeeds, the as_error.code value is usually set to AEROSPIKE_OK. There are some operations which may have other success status codes, so please review each operation for information on status codes.

When as_error.code is not a success value (AEROSPIKE_OK), then you can expect the other fields of as_error.code to be populated.

Example usage:

if ( aerospike_key_get(&as, &err, NULL, &key, &rec) != AEROSPIKE_OK ) {
fprintf(stderr, "(%d) %s at %s[%s:%d]\n", error.code, err.message, err.func, err.file. err.line);
}
@ AEROSPIKE_OK
Definition as_status.h:128
AS_EXTERN as_status aerospike_key_get(aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_record **rec)
char message[AS_ERROR_MESSAGE_MAX_SIZE]
Definition as_error.h:103
const char * file
Definition as_error.h:113
uint32_t line
Definition as_error.h:118
const char * func
Definition as_error.h:108

You can reuse an as_error with multiple operations. Each operation internally resets the error. So, if an error occurred in one operation, and you did not check it, then the error will be lost with subsequent operations.

Example usage:

if ( aerospike_key_put(&as, &err, NULL, &key, rec) != AEROSPIKE_OK ) {
fprintf(stderr, "(%d) %s at %s[%s:%d]\n", error.code, err.message, err.func, err.file. err.line);
}
if ( aerospike_key_get(&as, &err, NULL, &key, &rec) != AEROSPIKE_OK ) {
fprintf(stderr, "(%d) %s at %s[%s:%d]\n", error.code, err.message, err.func, err.file. err.line);
}
AS_EXTERN as_status aerospike_key_put(aerospike *as, as_error *err, const as_policy_write *policy, const as_key *key, as_record *rec)

Definition at line 93 of file as_error.h.

#include "as_error.h"

+ Collaboration diagram for as_error:

Data Fields

as_status code
 
const char * file
 
const char * func
 
bool in_doubt
 
uint32_t line
 
char message [AS_ERROR_MESSAGE_MAX_SIZE]
 

Related Symbols

(Note that these are not member symbols.)

static void as_error_append (as_error *err, const char *str)
 
static void as_error_copy (as_error *trg, const as_error *src)
 
static as_erroras_error_init (as_error *err)
 
static as_status as_error_reset (as_error *err)
 
static void as_error_set_in_doubt (as_error *err, bool is_read, uint32_t command_sent_counter)
 
#define as_error_set_message(__err, __code, __msg)    as_error_setall( __err, __code, __msg, __func__, __FILE__, __LINE__ );
 
static as_status as_error_setall (as_error *err, as_status code, const char *message, const char *func, const char *file, uint32_t line)
 
static as_status as_error_setallv (as_error *err, as_status code, const char *func, const char *file, uint32_t line, const char *fmt,...)
 
AS_EXTERN char * as_error_string (as_status status)
 
#define as_error_update(__err, __code, __fmt, ...)    as_error_setallv( __err, __code, __func__, __FILE__, __LINE__, __fmt, ##__VA_ARGS__ );
 

Friends And Related Symbol Documentation

◆ as_error_append()

static void as_error_append ( as_error * err,
const char * str )
related

Append string to error message.

Definition at line 275 of file as_error.h.

References message.

◆ as_error_copy()

static void as_error_copy ( as_error * trg,
const as_error * src )
related

Copy error from source to target.

Definition at line 259 of file as_error.h.

References code, file, func, in_doubt, line, and message.

◆ as_error_init()

static as_error * as_error_init ( as_error * err)
related

Initialize the error to default (empty) values, returning the error.

Parameters
errThe error to initialize.
Returns
The initialized err.

Definition at line 163 of file as_error.h.

References AEROSPIKE_OK, code, file, func, in_doubt, line, and message.

◆ as_error_reset()

static as_status as_error_reset ( as_error * err)
related

Resets the error to default (empty) values, returning the status code.

Parameters
errThe error to reset.
Returns
AEROSPIKE_OK.

Definition at line 184 of file as_error.h.

References AEROSPIKE_OK, code, file, func, in_doubt, line, and message.

◆ as_error_set_in_doubt()

static void as_error_set_in_doubt ( as_error * err,
bool is_read,
uint32_t command_sent_counter )
related

Set whether it is possible that the write transaction may have completed even though this exception was generated. This may be the case when a client error occurs (like timeout) after the command was sent to the server.

Definition at line 247 of file as_error.h.

References AEROSPIKE_ERR_TIMEOUT, code, and in_doubt.

◆ as_error_set_message

#define as_error_set_message ( __err,
__code,
__msg )    as_error_setall( __err, __code, __msg, __func__, __FILE__, __LINE__ );
related

Set all as_error fields and default in_doubt to false. Variable arguments are not accepted.

Definition at line 146 of file as_error.h.

◆ as_error_setall()

static as_status as_error_setall ( as_error * err,
as_status code,
const char * message,
const char * func,
const char * file,
uint32_t line )
related

Sets the error.

Returns
The status code set for the error.

Definition at line 203 of file as_error.h.

References AS_ERROR_MESSAGE_MAX_SIZE, as_strncpy(), code, file, func, in_doubt, line, and message.

◆ as_error_setallv()

static as_status as_error_setallv ( as_error * err,
as_status code,
const char * func,
const char * file,
uint32_t line,
const char * fmt,
... )
related

Sets the error.

Returns
The status code set for the error.

Definition at line 222 of file as_error.h.

References AS_ERROR_MESSAGE_MAX_LEN, code, file, func, in_doubt, line, and message.

◆ as_error_string()

AS_EXTERN char * as_error_string ( as_status status)
related

Return string representation of error code. Result should not be freed.

◆ as_error_update

#define as_error_update ( __err,
__code,
__fmt,
... )    as_error_setallv( __err, __code, __func__, __FILE__, __LINE__, __fmt, ##__VA_ARGS__ );
related

Set all as_error fields and default in_doubt to false. Variable arguments are accepted.

Definition at line 138 of file as_error.h.

Field Documentation

◆ code

as_status as_error::code

Numeric error code

Definition at line 98 of file as_error.h.

◆ file

const char* as_error::file

Name of the file where the error occurred.

Definition at line 113 of file as_error.h.

◆ func

const char* as_error::func

Name of the function where the error occurred.

Definition at line 108 of file as_error.h.

◆ in_doubt

bool as_error::in_doubt

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

Definition at line 125 of file as_error.h.

◆ line

uint32_t as_error::line

Line in the file where the error occurred.

Definition at line 118 of file as_error.h.

◆ message

char as_error::message[AS_ERROR_MESSAGE_MAX_SIZE]

NULL-terminated error message

Definition at line 103 of file as_error.h.


The documentation for this struct was generated from the following file: