Arcsde API about Error handling

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);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值