pátek 27. února 2009

... throw exception from ActiveX to Javascript

Developing a simple ActiveX I was not able to find clear information how to propagate exception from C++ code to Javascript. I'm using ATL and there are no exceptions when using ATL code.

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;
}

pátek 20. února 2009

středa 11. února 2009

... sentence of the month

Even the tchnical writer is able to write sentences that are not boring:

Chapter 8 revisits the definition and declaration criteria to a depth that will cause decompression sickness when you surface.

[credits]

neděle 1. února 2009

... když whisku, tak dobrou


Měl jsem příležitost ochutnat skotské sladové whisky "single malt" - nemíchané z jednoho sladu kvašené a pálené, v dubových sudech vyzrávající minimálně deset let. Chuti to byly různé od pohlazení až po drsnou kouřem z rašeliny vonící drsné.

Doporučuji.