...

View Full Version : delphi 6 NMFTP and TRY Exceptions



sir pannels
10-22-2008, 10:28 PM
hi all,

I've been using NMFTP to connect to a server... and it works fine, however when I try and wrap a TRY EXCEPTION on the connection code, if it fails to connect then the application bombs out and gives me a nasty windows/network error, it does not execute the code in my exception block.. I wonder if any one can spot what I have done.. I may well have misunderstood the situation...



try
NMFTP1.Host := 'hidden.com';
NMFTP1.Port := 21;
NMFTP1.UserID := 'hidden';
NMFTP1.Password := 'hidden';
NMFTP1.Connect;
ShowMessage('ok');
except
ShowMessage('failed');
end;
end;

So it should try connect, if it fails.. but I want it to display my failed message not the standard error dialouge... as im typing this I thinking that it does run my execption code because the code does error, it just can connect... dang... so on that thinking, if that is the case.. does anyone know away to achevie what I'm trying to do here? show a message and hide all over generic errors if it cant connect?

thanks for your time all :)
Sir P

AlexV
10-23-2008, 06:38 PM
Try something like that instead:


NMFTP1.Host := 'hidden.com';
NMFTP1.Port := 21;
NMFTP1.UserID := 'hidden';
NMFTP1.Password := 'hidden';
try
NMFTP1.Connect;
except
on E: Exception do
ShowMessage('Failed! Error = ' + E.Message);
end;

sir pannels
10-24-2008, 11:22 PM
Thanks wolf :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum