开发者

Which is the best way to put a try-except-finally in delphi? [duplicate]

This question already has answers here: Closed 11 years ago.

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜