Yes.
Long story short, our three tier software reports exceptions on the
server as strings which only contain the error message. On the client these
are all raised as EDatabaseError. I want to send exception types from the server
to the client. So we planned to change the server's SendClientException method
(which just sends a string) to also include the class of the exception then
use a Factory (or is it AbstractFactory, whatever Websnap uses for it's web
modules, that style of thing) to create an exception of the right type on the
client. However, there are places where the server's SendClientException is
called when there is no existing exception object, just an error message. We
want all exception strings recieved by the client to be in the same format to
ease the unpacking burden.
Existing: SendClientException(msg: string);
We
want:
SendClientException(msg: string); overload;
SendClientException(E: Exception); overload; // This does the
work
So I
wanted:
procedure SendClientException(msg: string);
var
e: Exception;
begin
e := Exception.Create(msg);
try
SendClientException(e);
finally
e.Free;
end;
end;
Obviously this would be a bad place to raise an exception because it
would never get sent to the client.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17 2003 8:48 a.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Freeing exceptions?
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17 2003 8:48 a.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Freeing exceptions?
You are correct.Can you tell us why you would want to create an exception object without raising it though?Cheers,C.-----Original Message-----
From: Allan, Samuel [mailto:[EMAIL PROTECTED]
Exception decends from TObject. Correct me if I am wrong, but if I create an exception and do not raise it, I then have to free it? But if I create an exception, muck about with it, and then raise it I do not have to free it?Is the below code a memory leak?procedure TSam.Samuel;vare: Exception;begine := Exception.Create('Foobar');end;Is the below code okay?procedure TSam.TrySamuel;vare: Exception;begine := Exception.Create('Foobar');try//do some stufffinallye.Free;end;end;