Article View: borland.public.cppbuilder.database.multi-tier
Article #259Re: Return MIDAS error mesages
From: Big Stew
Date: Fri, 19 Jul 2002 15:50
Date: Fri, 19 Jul 2002 15:50
75 lines
2976 bytes
2976 bytes
I'd try stepping through the server code when calling the RS_Iniciar()
method from the client.
You will find that
int a = 1/0 ;
will not throw the exception class that your catch() block is expecting,
therefore no error is returned.
To test returning rich error information, why not try something like;
STDMETHODIMP TQARiskAppSrvrImpl::RS_Iniciar()
{
String ErrMsg = "An Error occured!" ;
return Error(ErrMsg.Message.c_str(), IID_IQARiskAppSrvr);
}
If it's any help, I always use the following functions to decode rich error
information returned from my COM servers;
On the client enclose all COM server calls like so;
CheckResult(MyServer->MyMethod()) ;
and CheckResult is defined as follows;
const CODE_BASE = 0x300 ;
// Retrieve any error information from a HRESULT returned by a COM call
// If the HRESULT contains error info, we throw an EOleException
void CheckResult(HRESULT hr)
{
if (FAILED(hr))
{
WideString EDesc ;
WideString ESrc ;
WideString EHlpFile ;
ULONG EHlpCtx = 0 ;
IErrorInfo* ErrorInfo = NULL ;
if (SUCCEEDED(GetErrorInfo(0, &ErrorInfo)))
{
ErrorInfo->GetDescription(&EDesc) ;
ErrorInfo->GetSource(&ESrc) ;
ErrorInfo->GetHelpFile(&EHlpFile) ;
ErrorInfo->GetHelpContext(&EHlpCtx) ;
ErrorInfo->Release() ;
}
throw EOleException(EDesc, HResultToNumber(hr), ESrc, EHlpFile, EHlpCtx) ;
}
}
int HResultToNumber(int hr)
{
return HRESULT_CODE(hr) - CODE_BASE ;
}
Note that this assumes that the COM class derives from
ISupportErrorInfoImpl, which it will if the server was created using the
Builder COM wizards.
BigStew
"Carlos F. Quijano" <cquijanot@cable.net.co> wrote in message
news:3d3721ba_1@dnews...
> Hi again...
>
> Well , I try to use your code but my program no works.
>
> Is any interface required?
>
> When I try to read 'er', allways is null , why?
>
> Ths again!
>
> Carlos
Technical Details
Message-ID:
<3d383551_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!newsfeed.ision.net!ision!news.belwue.de!news.uni-stuttgart.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnewsReferences:
<3d34457c$1_2@dnews> <hs1ajugvj0on4o3rlg7q9g3mo6319ggmij@4ax.com> <3d35edec_1@dnews> <7docju8kok5dhnrdu4t0mmvbju70rjpvr3@4ax.com> <3d3721ba_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcd2b,8d4f5f1f9527f08e X-Google-Attributes: gidfcd2b,public X-Google-ArrivalTime: 2002-07-19 09:06:29 PST From: "Big Stew" <Big_Stew@talk21.com> Newsgroups: borland.public.cppbuilder.database.multi-tier References: <3d34457c$1_2@dnews> <hs1ajugvj0on4o3rlg7q9g3mo6319ggmij@4ax.com> <3d35edec_1@dnews> <7docju8kok5dhnrdu4t0mmvbju70rjpvr3@4ax.com> <3d3721ba_1@dnews> Subject: Re: Return MIDAS error mesages Date: Fri, 19 Jul 2002 16:50:25 +0100 Lines: 78 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 212.19.90.97 Message-ID: <3d383551_1@dnews> X-Trace: dnews 1027093841 212.19.90.97 (19 Jul 2002 08:50:41 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!newsfeed.ision.net!ision!news.belwue.de!news.uni-stuttgart.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews