• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • Last Modified:

PowerSock Exception Handling

Hi.  I'm trying to use the TPowersock component or the NMHTTP component.  My problem arises when I try to conenct to a host and the connection fails.  The ConnectionFailed function is called, I do what I want, but then my program crashes and Delphi gives me a message box saying "raised exception class ESockError with message: 'Conenction Failed'".  How do I correctly handle the ConnectionFailed event ( and deal with the exception ) so that it won't give the messagebox and crash my program?

Thanks in advance.
0
wizardtim
Asked:
wizardtim
1 Solution
 
SvisjCommented:
hi!
Maybe this will help you

bogustarget := false;
try
NMHttp1.Get(Edit1.Text);
 except
on E: ESockError do bogustarget := true;
on E: EInvalidOperation do bogustarget := true;
//etc...
end;

You will know that "if bogustarget = true" then the Nmhttp.Component didn't do anything but raise exceptions!

In debug mode it is possible to turn off "exception notifications", but I don't know how to do that exactly. But it is not nessecary because when you compile the file and run the EXE file (not from Delphi), the messages you have trapped should not show.

In debug mode just press Enter and F9 to accept the notification, if you have handled it correctly it should not CRASH your app 8=) Hope this helps!  
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now