Borland C++ Builder provides the function OleCheck(HRESULT Result);
. Its description in the documentation is this:
OleCheck is used to wrap many COM routines, so that if that routine fails, users will have an opportunity to handle it in the resulting exception that is raised.
If ECode is a value less than zero, OleCheck raises an EOleSysError exception that specifies the error code.
What is the recommended function or idiom to use with Microsoft ATL for throwing an exception if a function returns a failed status value? I'd like to avoid mixing Borland and Microsoft libraries in code like this:
CComPtr<Outlook::Explorers> spExplorers;
OleCheck(m_spApp->get_Explorers(&spExplorers));