Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Jul : Indy 10 - TIdFTPServer and exceptions
| Subject: | Indy 10 - TIdFTPServer and exceptions |
| Posted by: | "Adrien Reboisson" (adrien-reboissonatastasedotcom@nospam.fr) |
| Date: | 25 Jul 2005 05:23:54 |
Hi !
I'm using the TIdFTPServer component (D7 & Indy 10) to make a small FTP server. It works fine, but I don't understand the way to "propagate" exceptions to the client.
Let's say I have then following event handler to handle the "DELE" command :
procedure TFtpServer.DeleteFileHandler(ASender: TIdFTPServerContext;
const APathName: String);
var
LLocal: string;
begin
LLocal := ToLocalPath(ExpandPath(ASender.CurrentDir, APathName));
if not FileExists(LLocal) then
raise Exception.Create('File does not exists.')
else
DeleteFile(LLocal);
end;
Okay, now I test my server by using ftp.exe. If the file exists, no problem. But if the file does not exists, I get the following result :
ftp> quote DELE foooo
200-Ok
200 File does not exists.
Why "Ok" is sent before my error message ? Furthermore, why keeping a 2xx response code which means "Positive Completion reply" when the server handle an exception thrown by an event handler ? It should be something like 4xx or 5xx error code... or is it the developper's responsibility the set the error code and something else to say to the server component "hey, please send back an error to the client" ? Or it's a normal behavior and I'm wrong ?
Best regards,
A.R.