获取有关生成的最后一个异常的诊断信息。有关当前线程上生成的最后一个异常的信息在 CCI_EXCEPTION_ST 输出结构中返回。用户定义的扩展可以使用此函数来确定当实用程序函数返回错误代码时是否需要任何恢复。
当通过将 returnCode 设置为 CCI_EXCEPTION,向实用程序函数表明发生了异常时,可能调用此函数。
如果 char* 是 US-ASCII,则与异常关联的 traceText 将转换为 char*。如果 traceText 使用另一种语言,则使用 cciGetLastExceptionDataW 及与其关联的 CCI_EXCEPTION_WIDE_ST 结构(它以 UTF-16 的格式存储 traceText)。
如果代理或 cciThrowExceptionW 已引发异常,则 CCI_EXCEPTION_ST 结构的 traceText 元素将为空字符串。
typedef struct exception_st { int versionId; /* Structure version identification */ int type; /* Type of exception */ int messageNumber; /* Message number */ int insertCount; /* Number of message inserts */ CCI_STRING_ST inserts[CCI_MAX_EXCEPTION_INSERTS]; /* Array of message insert areas */ const char* fileName; /* Source: file name */ int lineNumber; /* Source: line number in file */ const char* functionName; /* Source: function name */ const char* traceText; /* Trace text associated with exception */ CCI_STRING_ST objectName; /* Object name */ CCI_STRING_ST objectType; /* Object type */ } CCI_EXCEPTION_ST; CCI_EXCEPTION_ST exception_st = malloc(sizeof(CCI_EXCEPTION_ST)); int rc = 0; memset(&exception_st,0,sizeof(exception_st)); cciGetLastExceptionData(&rc, &exception_st);