Article View: borland.public.cppbuilder.internet.socket
Article #3731Re: Exception handling
From: Remy Lebeau (TeamB)
Date: Mon, 13 Jun 2005 21:43
Date: Mon, 13 Jun 2005 21:43
51 lines
3159 bytes
3159 bytes
"Jan Slansk" <p.prm@seznam.cz> wrote in message
news:42adf4b0$1@newsgroups.borland.com...
> IdHTTP1->Port = 80;
> IdHTTP1->Host = "123.123.123.123";
Get rid of those. They are useless in TIdHTTP as they get overwritten when
the URL is parsed.
>
IdHTTP1->Post("http://123.123.123.123:80/Default.aspx",(TStream*)str1,(TStre
am*)str2);
You are posting an empty input stream. That doesn't do you any good,
either, so you may as well not even use it at all:
IdHTTP1->Post("http://123.123.123.123:80/Default.aspx", str2);
> Exceptions that I want to catch are real exceptions (EIdSocketError
> with message no route to host or EIdHTTPProtocolException with
> message 403 forbidden)
That is not what I meant. Of course they are real exceptions. But they may
be getting handled inside of Indy's internals and not propegating far enough
to reach your own code. The debugger always catches all exceptions
regardless of where they occur. If your last ShowMessage() is not being
called, then the exceptions are not actually reaching your own code, in
which case you can just ignore them since Indy is handling them internally
and your code will never see them when running outside of the debugger.
> And when I run my program in IDE's debugger, I see debug exception
> window with class name of exception and it's message
As well you should be. That is what the debugger is supposed to do. That
does not necessarily mean that the exceptions will reach your own code,
though.
> 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.
I highly doubt that. If Delphi can catch it, so can you. That is why I
told you to display the actual ClassName, so that you could see the actual
ClassName that is being thrown and can then update your catch statements
accordingly. Or, if you just catch Exception or EIdException directly and
not any specific derived classes, then you will be catching all possible
exceptions that can reach your own code.
Gambit
Technical Details
Message-ID:
<42ae03d6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<42ada95b@newsgroups.borland.com> <42adbc9f@newsgroups.borland.com> <42ade312$1@newsgroups.borland.com> <42adea88$1@newsgroups.borland.com> <42adf4b0$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 From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <42ada95b@newsgroups.borland.com> <42adbc9f@newsgroups.borland.com> <42ade312$1@newsgroups.borland.com> <42adea88$1@newsgroups.borland.com> <42adf4b0$1@newsgroups.borland.com> Subject: Re: Exception handling Date: Mon, 13 Jun 2005 14:43:16 -0700 Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <42ae03d6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1118700502 68.69.17.41 (13 Jun 2005 15:08:22 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail