from http://edndoc.esri.com/arcsde/9.1/capi_concepts/error_handling.htm
Most ArcSDE functions return a numeric error code. Passing the code to the SE_error_get_string function allows you to retrieve a text string message for a particular ArcSDE error or warning code. The SE_connection_get_ext_error and the SE_stream_get_ext_error functions can provide additional information when a database error (SE_DB_IO_ERROR) is returned. The SE_stream_get_ext_error function should be used for all stream functions except SE_stream_create. SE_connection_get_ext_error can be used for all other functions except SE_connection_create, which handles its own extended error codes.
The following function demonstrates the use of the ArcSDE software’s error handling routines. Pass a NULL for the connection and stream handles when handling stream errors. For all other error checking, pass the connection handle and a NULL to the stream handle.
/****************************************************************************
check_error This function prints nonsuccessful error codes.
****************************************************************************/
static void check_error (SE_CONNECTION Connection, SE_STREAM Stream, LONG rc, CHAR *comment)
{
SE_ERROR error;
CHAR error_string[SE_MAX_MESSAGE_LENGTH];
LONG temp_rc;
if ( (rc != SE_SUCCESS) && (rc != SE_FINISHED) )
{
error_string[0] = '/0';
SE_error_get_string (rc, error_string);
printf ("%s encountered a %d error:/n%s/n", comment, rc, error_string);
/* Print extended error info, if any */
if ( (SE_DB_IO_ERROR == rc) | (SE_INVALID_WHERE == rc) )
{
if (NULL == Connection)
{
/* Assume this is a stream error */
temp_rc = SE_stream_get_ext_error (Stream, &error);
}
else
{
/* Assume this is a connection error */
temp_rc = SE_connection_get_ext_error (Connection, &error);
}
if (SE_SUCCESS == temp_rc)
printf ("Extended error code: %d, extended error string:/n%s/n", error.ext_error, error.err_msg1);
}
exit (0);
}
}