Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - How to catch an exception thrown by MSXML? [Thread Next] Re: How to catch an exception thrown by MSXML?To: NULL Date: 10/1/2008 9:40:00 PM
"JoeSchmoe112" <JoeSchmoe112@d...> wrote in message
news:41619253-B8E2-4EE4-9D7C-C1F03086B966@m......
> Consider this function:
>
> BOOL GetSingleNodeV(const MSXML2::IXMLDOMDocumentPtr pXMLDoc, const
> CString
> &strPath, CString &StrValue)
> {
> BOOL bRetCode=FALSE;
>
> BSTR bstrQstr = strPath.AllocSysString();
> IXMLDOMNodePtr o;
> o = pXMLDoc->selectSingleNode( bstrQstr);
> if (o!=NULL)
> {
> HRESULT hr=o->get_text(&bstrQstr);
> if (hr==S_OK)
> {
> StrValue = bstrQstr;
> bRetCode = TRUE;
> }
> else
> {
> StrValue="";
> }
> }
> //o->Release();
> SysFreeString(bstrQstr);
>
> return bRetCode;
> }
>
> Call to selectSingleNode sometimes works as expected but sometimes it
> throws
> an exception. How can I extract additional information about this
> exception?
You can access details about errors generated by COM components with the
_com_error exception:-
try
{
// your code
}
catch (_com_error &e)
{
// here you can use _com_error members such as e.Description()
}
--
Anthony Jones - MVP ASP/ASP.NET
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
