eXtremeDB error code

来源:互联网 发布:mac版搜狗五笔造词 编辑:程序博客网 时间:2024/05/01 14:30
The following example demonstrates this procedure (note that this code is taken 
from the 06_errorhandling_fatalerr sample):
static void errhandler( int n )
{
printf( "\n eXtremeDB runtime fatal error: %d", n );
getchar();
exit( -1 );
}
void main()
{
...
mco_error_set_handler( &errhandler );
...
rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
if ( MCO_S_OK == rc ) {
printf("\n\n\tThe following attempt to create a new record\n"
"\tshould cause the Error handler to be called with Fatal\n"
"\tError 340049 because it requires a READ_WRITE transaction.\n"
"\tThe type of transaction started was MCO_READ_ONLY...\n"
"\tNote: you will get error code instead of fatal error if\n"
"\tthe program was linked not against _check runtime\n");
/* anObject_new() should fail with error code 340049 = 
MCO_ERR_TRN+49 */
rc = anObject_new(t, &rec);
if ( MCO_S_OK == rc ) {
rc = anObject_data_put(&rec, data);
/* the following code will not be reached unless the 
transaction is
changed to MCO_READ_WRITE */
if ( MCO_S_OK == rc ) {
rc = mco_trans_commit(t);

} else if (rc == MCO_E_ACCESS) {
printf("\nThe sample was linked with no-check runtime\n");

rc = MCO_S_OK; 

}
...
}
When the above code is executed it causes the error handler to be called with the 
error code 340049 which generates the following output:
eXtremeDB runtime fatal error: 340049
Checking Appendix B, the error code value of 340000 corresponds to the constant 
MCO_ERR_TRN. This indicates an error in the transaction being performed. (The 
added value of 49 indicates the line within the runtime function where the 
assertion failed, causing mco_stop() to be called. This is useful if it is necessary 
to contact McObject support – or if the developer has a source code license.  For a 
more detailed explanation of error codes see Appendix B.)

原创粉丝点击