Exceptions in Constructors and Destructors
Check out Alister Christie’s latest movie on CodeGearGuru.com. He covers the elusive Exceptions in Constructors and Destructors. Thanks Alister. That was one of the questions from my Exceptional Exceptions session that I needed to follow up on.
Tags: , Delphi, exceptions, training
December 4th, 2007 at 3:58 am
There is one more way of doing it (if assuming that destructors do not raise exceptions):
var S1,S2:TSomeObject;
begin
S2:=nil;
S1:=TSomeObject.Create;
try
// Some Code 1
S2:=TSomeObject.Create;
// Some Code 2
finally
S1.Free;
S2.Free;
end;
December 5th, 2007 at 3:13 pm
Thanks for the mention ;-). I made this video because of a discussion I had with another Delphi community member about some of the lazy exception handling I’ve done in some of my other videos, I was kind of hoping that this one would make up for it.