Article View: borland.public.cppbuilder.internet.socket
Article #3730Re: Exception handling
From: Jan Slansk
Date: Mon, 13 Jun 2005 21:03
Date: Mon, 13 Jun 2005 21:03
56 lines
2621 bytes
2621 bytes
> Please show your exact code. Have you tried this yet?
>
> try {
> IdHTTP1->Post("address", str1, str2);
> }
> catch(const Exception &e) {
> ShowMessage(e.ClassName);
> }
>
Yes, I tied.
Here is code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TIdHTTP *IdHTTP1;
TStringStream *str1,*str2;
str1 = new TStringStream(NULL);
str2 = new TStringStream(NULL);
IdHTTP1 = new TIdHTTP(NULL);
IdHTTP1->Port = 80;
IdHTTP1->Host = "123.123.123.123";
try
{
ShowMessage("Before");
IdHTTP1->Post("http://123.123.123.123:80/Default.aspx",(TStream*)str1,(TStream*)str2);
ShowMessage("After");
}
catch(const Exception &e)
{
ShowMessage(e.ClassName);
}
}
> running the project inside the IDE's debugger, you might just be seeing the
> debugger catching exceptions that are internal to Indy which never actually
> reach your code in the first place.
Exceptions that I want to catch are real exceptions (EIdSocketError with
message no route to host or EIdHTTPProtocolException with message 403
forbidden), and I think that they are not like exception "connection
closed gracefully". And when I run my program in IDE's debugger, I see
debug exception window with class name of exception and it's message,
and when I run it directly as standalone binary I see error window with
exception's message (for example massage with text "403 HTTP/1.1
Forbidden"). But still not able to catch it.
Technical Details
Message-ID:
<42adf4b0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42ada95b@newsgroups.borland.com> <42adbc9f@newsgroups.borland.com> <42ade312$1@newsgroups.borland.com> <42adea88$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,a561ce3cd6ae6110 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 13 Jun 2005 23:03:47 +0200 From: Jan Slansk <p.prm@seznam.cz> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: Exception handling References: <42ada95b@newsgroups.borland.com> <42adbc9f@newsgroups.borland.com> <42ade312$1@newsgroups.borland.com> <42adea88$1@newsgroups.borland.com> In-Reply-To: <42adea88$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 195.113.65.3 Message-ID: <42adf4b0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1118696624 195.113.65.3 (13 Jun 2005 14:03:44 -0700) Lines: 56 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail