Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Throwing Errors (in ATL)

Status
Not open for further replies.

MattWoberts

Programmer
Oct 12, 2001
156
GB
Hi all,

Does anyone know how to throw a _com_error in ATL? I want to throw an error and set the description of the error somehow. Do I need to create a HRESULT or something?

Helllppppp!!
 
When you create a new ATL object, you should go to the Attributes tab and check Support ISupportErrorInfo.

Then you can add rich error support using the following construct...


if(condition)
{
}

else
{
// this will generate a com exception
return Error(L"Long description of the exception",
IID_yourobject, E_FAIL);
}
 
Thanks, I think I have cracked it! I was trying to throw _com_error's and getting very confused, raising a simple Error is working well!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top