vc++ 异常输出的问题
我想把异常的信息输出来,可是怎么总也没有信息呢?我把e.Error(),e.ErrorInfo(),e.ErrorMessage()都用过,结果是:Unknown error 0x800A151C,为什么呢?
try {
}catch(_com_error & e) {
printf( "exception:%s ",e.ErrorMessage());
}
[解决办法]
Microsoft Specific
Retrieves the string message for HRESULT stored in the _com_error object.
const TCHAR * ErrorMessage( ) const throw( );
Return Value
Returns the string message for the HRESULT recorded within the _com_error object. If the HRESULT is a mapped 16-bit wCode, then a generic message "IDispatch error # <wCode> " is returned. If no message is found, then a generic message "Unknown error # <hresult> " is returned. The returned string is either a Unicode or multibyte string, depending on the state of the _UNICODE macro.
If no message is found, then a generic message "Unknown error # <hresult> " is returned.
意味什么?
[解决办法]
它上面的意思就是没有发现错误信息就返回“Unknown error XXXX”.
就是你上面的那个情况。