Error Handling


Detailed Description

Errors, warnings, return codes, and related helper functions.

Many errors can occur during a C API function call. When an error occurs, an error code is set that indicates the kind of error encountered. To retrieve the most recent error code, call get_db_error. You can check the error code with DB_SUCCESS or DB_FAILED to determine whether the call was successful. Some error codes are only warnings, and are considered success. Warnings are represented by positive values, while errors are indicated by negative values.

You can also check whether a C API function call was successful by inspecting the return value. Many API functions return a value of type db_result_t. In this case, the value is either DB_OK if the call was successful, or DB_FAIL if not. Any function that returns a handle type (e.g. db_t) will return NULL in case of failure.

The following list indicates what value will be returned when a function with the given return type encounters an error:


Data Structures

struct  ErrorInfo
 Error information. More...

Error support routines

int set_db_error (_dbstatus_t rc_t)
_dbstatus_t get_db_error ()
_dbstatus_t clear_db_error ()
void save_db_error (ErrorInfo *)
void restore_db_error (const ErrorInfo *)
#define DB_PUSH_ERROR(__error_info__)   save_db_error(&__error_info__)
#define DB_POP_ERROR(__error_info__)   restore_db_error(&__error_info__)
#define DB_SET_ERROR(x)   set_db_error(x)
#define DB_RAISE_ERROR(x)   return DB_SET_ERROR(x)
#define DB_THROW_ERROR(x)   do { int __rc__ = (x); if (DB_FAILED(__rc__)) DB_RAISE_ERROR(__rc__); } while(0)
#define DB_ONERROR_GOTO(x, lab)   do { int __rc__ = (x); if (DB_FAILED(__rc__)) goto lab; } while(0)

Error codes

#define DB_NOERROR   (0)
#define DB_FAILURE   (-1)

OS errors

#define DB_EBADF   (_dbstatus_t) -2
#define DB_EEXIST   (_dbstatus_t) -3
#define DB_ENOENT   (_dbstatus_t) -4
#define DB_ENOSPACE   (_dbstatus_t) -5
#define DB_EIO   (_dbstatus_t) -6
#define DB_EACCESS   (_dbstatus_t) -7
#define DB_EEXTEND   (_dbstatus_t) -8
#define DB_EDEADLOCK   (_dbstatus_t) -9
#define DB_ELOCKED   (_dbstatus_t)-10

Argument errors

#define DB_EINVAL   (_dbstatus_t)-11
#define DB_ERANGE   (_dbstatus_t)-12
#define DB_ESTATE   (_dbstatus_t)-13
#define DB_ENOTIMPL   (_dbstatus_t)-14
#define DB_ENOMEM   (_dbstatus_t)-15
#define DB_EOSERROR   (_dbstatus_t)-16
#define DB_ENOTAPPLICABLE   (_dbstatus_t)-17
#define DB_ENOTHREAD   (_dbstatus_t)-18
#define DB_EINTERNAL   (_dbstatus_t)-19
#define DB_EINVPATH   (_dbstatus_t)-20
#define DB_ESOCKETSTARTUP   (_dbstatus_t)-50
#define DB_ESOCKETOPEN   (_dbstatus_t)-51
#define DB_ESOCKET   (_dbstatus_t)-52
#define DB_ESOCKETHOSTNAME   (_dbstatus_t)-53
#define DB_ESOCKETCONNECTION   (_dbstatus_t)-54
#define DB_ESOCKETRECV   (_dbstatus_t)-55
#define DB_ESOCKETSEND   (_dbstatus_t)-56

Error test routines

#define DB_SUCCESS(x)   ((int32_t)(x) >= DB_NOERROR)
#define DB_FAILED(x)   ((int32_t)(x) < DB_NOERROR)

General Errors

#define DB_EDUPLICATE   (_dbstatus_t)-100
#define DB_ENOTFOUND   (_dbstatus_t)-101
#define DB_ENOMOREDATA   (_dbstatus_t)-102
#define DB_EKEYOUTOFRANGE   (_dbstatus_t)-103
#define DB_EEMPTYRANGE   (_dbstatus_t)-104
#define DB_EBTREESLOTTOOLARGE   (_dbstatus_t)-105
#define DB_EBTREENEEDREVALIDATE   (_dbstatus_t)-106
#define DB_ENORECORD   (_dbstatus_t)-107
#define DB_ENAME   (_dbstatus_t)-109
#define DB_EROWRANGE   (_dbstatus_t)-110
#define DB_ESHUTDOWN   (_dbstatus_t)-111

Table Errors

#define DB_ETABLE   (_dbstatus_t)-120

Index Errors

#define DB_EINDEX   (_dbstatus_t)-130

Field Errors

#define DB_EFIELD   (_dbstatus_t)-140
#define DB_EDUPLICATEFIELDS   (_dbstatus_t)-141
#define DB_EFIELDSIZE   (_dbstatus_t)-142
#define DB_EBINDSIZE   (_dbstatus_t)-143
#define DB_EPARAM   (_dbstatus_t)-144

Sequence Errors

#define DB_ESEQ   (_dbstatus_t)-150
#define DB_ESEQ_OVERFLOW   (_dbstatus_t)-151

Row Errors

#define DB_EINVALROWTYPE   (_dbstatus_t)-160
#define DB_EINVALKEYTYPE   (_dbstatus_t)-161
#define DB_EKEYTOOSHORT   (_dbstatus_t)-162
#define DB_ERECORDSIZE   (_dbstatus_t)-163

Data Errors

#define DB_EDATA   (_dbstatus_t)-170
#define DB_ECONVERT   (_dbstatus_t)-171

Kernel Errors

#define DB_ENOBUFFER   (_dbstatus_t)-172
#define DB_ESTORAGE   (_dbstatus_t)-174
#define DB_ECRC   (_dbstatus_t)-175
#define DB_ERECOVERY   (_dbstatus_t)-176
#define DB_EUNDOSPACE   (_dbstatus_t)-177

Log Warnings

#define DB_SLOG_SPLIT   (_dbstatus_t)+180

Transaction Errors

#define DB_ENOTX   (_dbstatus_t)-190
#define DB_ETXSTATE   (_dbstatus_t)-191
#define DB_ETXACTIVE   (_dbstatus_t)-192

Shared Access Errors

#define DB_ENOLOCK   (_dbstatus_t)-200

Other Errors

#define DB_EUSER   (_dbstatus_t)-210
#define DB_EAPIVER   (_dbstatus_t)-220
#define DB_EEVALUATION   (_dbstatus_t)-250
#define DB_EIPCPROTO   (_dbstatus_t)-300
#define DB_EIPCINVAL   (_dbstatus_t)-301
#define DB_EIPCINVALMESSAGETAG   (_dbstatus_t)-302
#define DB_EIPCINVALPROCTAG   (_dbstatus_t)-303
#define DB_EIPCSTORAGEALREADYOPENED   (_dbstatus_t)-304
#define DB_EIPCSTORAGENOTOPENED   (_dbstatus_t)-305
#define DB_EIPCINVALHANDLE   (_dbstatus_t)-306
#define DB_EIPCNULLPARAM   (_dbstatus_t)-307
#define DB_EIPCTOOFEWPARAMS   (_dbstatus_t)-308
#define DB_EIPCINVALMESSAGESIZE   (_dbstatus_t)-309
#define DB_EIPCINVALMESSAGEFORMAT   (_dbstatus_t)-310
#define DB_EIPCINVALURL   (_dbstatus_t)-311
#define DB_EIPCINVALURLSCHEMA   (_dbstatus_t)-312
#define DB_EIPCENVSTARTUP   (_dbstatus_t)-313
#define DB_EIPCACCESS   (_dbstatus_t)-314
#define DB_EIPCMAXCONNECTIONS   (_dbstatus_t)-315

Defines

#define _DB_ERROR(n)   ((_dbstatus_t) -n)
#define _DB_WARNING(n)   ((_dbstatus_t) (1 + n))
#define DB_OK   ((db_result_t)1)
#define DB_FAIL   ((db_result_t)0)
#define DB_WTIME_FAIL   ((db_wtime_t)(-1))
#define DB_LEN_FAIL   ((db_len_t)(-1))
#define DB_ESQLCODESIZETOOLARGE   (_dbstatus_t)-400
#define DB_ESQLTABLENOTEXISTS   (_dbstatus_t)-401
#define DB_ESQLINVALIDCOLUMNNAME   (_dbstatus_t)-402
#define DB_ESQLCOLUMNAMBIGUOUSLYDEFINED   (_dbstatus_t)-403
#define DB_ESQLINCOMPATIBLETYPES   (_dbstatus_t)-404
#define DB_ESQLINVALIDFUNCTIONNAME   (_dbstatus_t)-405
#define DB_ESQLINVALIDNUMBEROFARGUMENTS   (_dbstatus_t)-406
#define DB_ESQLININVALIDARGUMENTTYPE   (_dbstatus_t)-407
#define DB_ESQLINVALIDNUMBER   (_dbstatus_t)-408
#define DB_ESQLINVALIDQUALIFIER   (_dbstatus_t)-409
#define DB_ESQLINCOMPATIBLEROWTYPES   (_dbstatus_t)-410
#define DB_ESQLPARSEERROR   (_dbstatus_t)-411
#define DB_ESQLNOTAGROUPBYEXPRESSION   (_dbstatus_t)-412
#define DB_ESQLFEATURENOTALLOWED   (_dbstatus_t)-413
#define DB_ESQLDIVIDEBYZERO   (_dbstatus_t)-414
#define DB_ESQLTYPECVTNOTIMPLEMENTED   (_dbstatus_t)-415
#define DB_ESQLOPERATIONNOTIMPLEMENTED   (_dbstatus_t)-416
#define DB_ESQLINVALIDRELATIONALOPERATOR   (_dbstatus_t)-417
#define DB_ESQLROWSIZETOOLARGE   (_dbstatus_t)-418
#define DB_ESQLNOTSORTABLETYPE   (_dbstatus_t)-419
#define DB_ESQLNOENOUGHVALUES   (_dbstatus_t)-420
#define DB_ESQLTOOMANYVALUES   (_dbstatus_t)-421
#define DB_ESQLBOOLEXPRESSIONINSELECTLIST   (_dbstatus_t)-422
#define DB_ESQLENV   (_dbstatus_t)-423
#define DB_ESQLINCONSISTENTPARAMTYPE   (_dbstatus_t)-424
#define DB_ESQLCOULDNOTDEDUCEPARAMTYPE   (_dbstatus_t)-425
#define DB_ESQLINVALIDPARAMINDEX   (_dbstatus_t)-426
#define DB_ESQLPARAMCONVERT   (_dbstatus_t)-427

Typedefs

typedef int _dbstatus_t
typedef struct rc_s * db_result_t


Copyright © 2005-2007 ITTIA®. All rights reserved.