[fpc-pascal] how to simplify try try except end finally end?
Dennis Poon
dennis at avidsoft.com.hk
Thu Dec 26 13:09:51 CET 2013
Is there a way to further simplify the following?
I need to make the exception message more indicative of the context of
the error and I hope to combine the 2
try blocks into one.
It seems possible in Java and C# but not in FPC.
Is there a way to combine them like
try
except
finally
end;
Dennis
------------
Obj := TSomeObject.Create;
TheContext := 'after object creation';
try
try
TheContext := 'Before doing task 1';
//task 1
TheContext := 'Before doing task 2';
//task 2
TheContext := 'Before doing task 3';
//task 3
finally
FreeAndNil(Obj);
end;
except
On E : Exception do begin
E.Message := TheContext+E.Message ;
raise;
end;
end;
-------------
More information about the fpc-pascal
mailing list