Possible Duplicate:
Delphi Exception Handling - How to clean up properly? Use of Try/Finally/Catch Together in Delp开发者_高级运维hi
I would like to know which is the best way to put try-except-finally
in delphi? What I mean is in nested try block, which statement should come inside, for example, Example 1
// initialize / allocate resource (create objects etc.)
...
try
try
// use resource
...
except
// handle exception
...
end;
finally
// free resource / cleanup
...
end
Example 2
// initialize / allocate resource (create objects etc.)
...
try
try
// use resource
...
finally
// free resource / cleanup
...
end;
except
// handle exception
...
end
Which is the best way to handle an exception in Delphi, Example 1 or Example 2. why?
精彩评论