Board index » cppbuilder » Re: TIdHttp Reponse Code

Re: TIdHttp Reponse Code


2003-07-18 08:08:30 PM
cppbuilder73
James Diskwave wrote:
Quote
so I figure that you should be able to do something with it and
prevent the application from crashing.
I don't use Indy so can't help with your specific problem. But if your
applications crashes simply because an exception is thrown, then you
have deeper problems than simply suppressing the exception. I would
also use this 'opportunity' to find those other bugs that are going to
come back and bite you at a less convenient time.
[It is also easy to preach the message while offering little actual
help, sorry about that, but I do hear alarm bells ringing]
--
AlisdairM
Team Thai Kingdom
 
 

Re:Re: TIdHttp Reponse Code

Hallo !
Quote
Using the TIdHttp.

How do I handle a response code.

For example if I get the url:
AnsiString result;
result = Get("www.diskwave.com");

the page returns a 403 (forbidden).

This causes TIdHttp to raise an exception.

How do I stop the exception and halt the process?
I have such a code in my program:
...
try{
IdHTTP1->Get("www.diskwave.com", MemStream);
}catch(Exception &e){
StatusBar1->SimpleText = e.Message;
}
...
But for more comprehensive logging I'm using a TIdLogEvent component,
OnReceived event.
P.S. You can find out more at news.atozedsoftware.com
Best regards, Constantine.
 

Re:Re: TIdHttp Reponse Code

James Diskwave wrote:
Quote
It does work.
Just not when it is run from the ide.
In that case you may want to ask in the IDE group about the 'break on
Exception' option in the de{*word*81} <g>
What you are seeing is normal behaviour, not a crash. It is an
extremely useful feature of the de{*word*81}!
Tools | De{*word*81} Options
Language Exceptions page
You have separate options to 'break on Exception' for C++ / VCL
exceptions.
There is also a filter list of exceptions that can be thrown without the
de{*word*81} jumping in (which you can add to yourself)
--
AlisdairM
Team Thai Kingdom
 

{smallsort}

Re:Re: TIdHttp Reponse Code

I tried this but I am still getting the exception crash.
try
{
Get("www.diskwave.com", result);
}
catch(Exception & e)
{
ShowMessage(e.Message);
}
 

Re:Re: TIdHttp Reponse Code

Quote
try
{
Get("www.diskwave.com", result);
}
catch(Exception & e)
{
ShowMessage(e.Message);
}


It does work.
Just not when it is run from the ide.
 

Re:Re: TIdHttp Reponse Code

"James Diskwave" <james at diskwave dot com>wrote in message
Quote
It does work.
Just not when it is run from the ide.
Yes, it does. The IDE de{*word*81} is designed to intercept exceptions before
your applicatio ndoes. But you can simply press F9 to pass the exception
back to the application for normal handling.
Gambit
 

Re:Re: TIdHttp Reponse Code

You can't stop the exception from being thrown. Exceptions are an
important
Quote
part of Indy's overall design, they are used all over the place. Simply
wrap the call to Get() in a try...catch block to intercept the exception
and
handle the response according.
Thanks.
That makes a bit ofscense now.
If I should use a catch to handle the exceptions then where can I find a
list of
thrown exceptions?
Exceptions do not seem to be documented.
James