The solutin is to implement
ISupportErrorInfo
and act accordingly when it's the only method is called (apropriate code is generated by Visual Studio). Then when an error is to be reported after a method of ActiveX control returns, use functions CreateErrorInfo/SetErrorInfo
to fill the error information data and use E_FAIL
return code of the method.Now an exception is thrown in Javascript in the form of Error object with message property, which maps to what was set by
ICreateErrorInfo.SetDescription
.That's all for today.
Example:
void setException(BSTR msg){
ICreateErrorInfo * cErrInf;
CreateErrorInfo(&cErrInf);
if (cErrInf==NULL) return;
cErrInf->SetDescription(msg);
cErrInf->SetGUID(component_IID);
IErrorInfo *err;
cErrInf->QueryInterface(&err);
SetErrorInfo(0,err);
}
...
setException(L"error mesaage");
return E_FAIL;
}