I’ve been finding bits and pieces to this answer on the web, but not a crystal clear solution.
Here’s what i’m trying to do.
1) Create an ATL Simple Object.
2) Add a method to that object which returns a BOOL, not an HRESULT. The caller wants true/false return values.
3) Throw an exception to a jscript or vbscript caller that will provide e.description and e.number data.
RE 2) I’ve found that I can use STDMETHODIMP_(BOOL) along with [local] to allow BOOL to be returned RE 3) I’ve found that I can pass IErrorInfo via SetErrorInfo() to populate the Error object
My dilemma is I can’t figure out how to architect C++ to throw an exception across the ABI boundary that won’t crash the caller.
When you write code for a scripting client then you must use a subset of COM called Automation. Which dictates that:
In particular that means that BOOL is not permitted, it must be VARIANT_BOOL. You declare a method that returns a boolean by writing it like this in IDL:
Assign VARIANT_TRUE or VARIANT_FALSE to *retval in your code. The scripting language uses natural syntax like
var = Foo().You generate an exception in the scripting client by returning a failure HRESULT.