If a two-way operation request fails, a Request Response Service must return a TIBCO ActiveEnterprise exception of some kind. TIBCO ActiveEnterprise exceptions can be defined for each method of a TIBCO ActiveEnterprise class in TIBCO Designer, as shown below.
Every TIBCO ActiveEnterprise Class used by the service component must have the exception TIBCOCOMADAPTER_EXCEPTION
of type string
defined for each method in the class. When a COM method invocation returns an unsuccessful HRESULT
to the service, the service tries to get additional information about the error through the IErrorInfo
interface, to pass it to the client.
If the COM object did not support the IErrorInfo
interface or if the service encounters any other kind of error, the service packages the numeric error code, and a textual description of the error (if possible) into a TIBCOCOMADAPTER_EXCEPTION
and returns this to the Request Response Invocation Service. Other Request Response Services may return exceptions of other kinds.
The CTestobj1::TestIErrorInfo
function in the testobj1.cpp
sample file below shows how the Error Information can be set by a COM object, taking advantage of the IErrorInfo
interface:
STDMETHODIMP CTestobj1::TestIErrorInfo(
/*<in,out>*/ int* iop1)
{
PRINT_ENTRY("TestIErrorInfo");
HRESULT hr;
if (*iop1 == 1)
{
CComPtr<ICreateErrorInfo> spCreateErrorInfo;
hr = CreateErrorInfo(&spCreateErrorInfo);
_ASSERTE(SUCCEEDED(hr));
hr = spCreateErrorInfo->SetSource(L"Testobj1");
_ASSERTE(SUCCEEDED(hr));
hr = spCreateErrorInfo->SetGUID(IID_ITestobj2);
_ASSERTE(SUCCEEDED(hr));
hr = spCreateErrorInfo->SetDescription(L"An error was generated.");
_ASSERTE(SUCCEEDED(hr));
CComPtr<IErrorInfo> spErrorInfo;
hr = spCreateErrorInfo->QueryInterface(
IID_IErrorInfo,
(void**)&spErrorInfo
);
_ASSERTE(SUCCEEDED(hr));
hr = SetErrorInfo(0, spErrorInfo);
_ASSERTE(SUCCEEDED(hr));
hr = 0xE2000004L; // Some error code.
}
else if (*iop1 == 2)
{
hr = E_INVALIDARG;
}
else if (*iop1 == 3)
{
hr = 0xFF000004L; // Some error code.
}
else
{
hr = S_OK;
}
PRINT_RETURN("TestIErrorInfo");
return hr;
}
TIBCO Adapter™ for COM User’s Guide Software Release 5.3, September 2005 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |