# C API Return Codes

> The eXtremeDB runtime returns integer codes indicating success or failure for most C API functions. The runtime returns three different types of return code:

> - Status Codes (MCO_S_*): indicate runtime states that can and will occur during normal database operations;
> - Non-Fatal Error Codes (MCO_E_*): indicate runtime error conditions that the application can manage by responding appropriately; and
> - Fatal Error Codes (MCO_ERR_*): indicate bugs in the application code that render the runtime unable to safely continue execution.

> The following function code from the runtime file `mcocsr.c` illustrates the use of each of the three return code types:

>         MCO_RET mco_cursor_check(mco_trans_h t, mco_cursor_h c0)
>         {
>             mco_scursor_t* c = (mco_scursor_t*)(c0);
>             mco_objhandle_t obj;
>             MCO_RET rc;

>             #ifdef MCO_CFG_CHECKLEVEL_1
>             if (!CHECK_TRANSACTION((mco_db_connection_h)t))
>             {
>                 mco_stop(MCO_ERR_TRN + 5);

>             }
>             #endif

>             if (c->mark != MCO_DB_CURSOR_MARK || c->endmark != MCO_DB_CURSOR_MARK)
>             {
>                 return MCO_E_INVALID_HANDLE;
>             }

>             rc = mco_w_obj_from_cursor(t, c0, c->csr_class_code, &obj);
>             if (rc != MCO_S_OK)
>             {
>                 return MCO_E_CURSOR_INVALID;
>             }

>             return MCO_S_OK;
>         }

> Note the MCO_S_* and MCO_E_* type return codes are returned directly from the runtime function to be managed by the application code. But the MCO_ERR_* type return codes are passed to the runtime function `mco_stop()` to terminate execution. Fatal error conditions can cause a runtime exception or, in C and C++ applications, can be trapped by a fatal error handler; if a fatal error handler is not registered for the application, a fatal error can cause the application to appear to hang. Please see the Fatal Error Codes page for further explanation of these return codes and how to determine their cause.

> Please use the links below to view the meanings for the different categories of eXtremeDB return codes:

> Status Codes | Values 0 through 19
> Non-fatal Error Codes | Values 49 through 99 and 999
> Disk Manager Error Codes | Values 100 through 199
> XML Error Codes | Values 200 through 299
> Network Error Codes | Values 300 through 399
> HA Error Codes | Values 400 through 499
> UDA Error Codes | Values 500 through 599
> Transaction Logging Error Codes | Values 600 through 699
> Sequence Error Codes | Values 700 through 799
> Data Definition Language Error Codes | Values 800 through 899
> Cluster Error Codes | Values 900 through 998
> Performance Monitor and Miscellaneous Error Codes | Values 1000 through 1100
> IoT Specific Error Codes | Values 1200 through 1299
> Fatal Error Codes | Values 100000 through 1999999
> Feed Handler Specific Return Codes | Values 0 through 10
> Web Services Specific Return Codes | Values 0 through 11