Wilfried Mestdagh wrote:
> I know that an exception handler destroy the Exception object, eg in
> this case it is automaticly free:
>
> try
> if Condition then
> raise Exception.Create('Foo');
> except
> on E: Exception do
> TriggerError(E);
> end;
>
> But question is what in this case:
>
> if Condition then begin
> E := Exception.Create('Foo');
> TriggerError(E);
> end;
>
> There is no Raise, no Exception block, so do I have to Free the
> Exception object here ?
If there is no "raise" statement, then Delphi treats the exception
object the same way it treats any other object. It doesn't free things
for you.
E := Exception.Create('Foo');
try
TriggerError(E);
finally
E.Free;
end;
However, the name of your TrigerError procedure doesn't seem right.
You're not really _triggering_ the error in that procedure. The error
has already occured, and you're telling the procedure what the error was.
--
Rob
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk