通常,我会这样做:
try
{
code
code that might throw an anticipated exception you want to handle
code
code that might throw an anticipated exception you want to handle
code
}
catch
{
}
这样做有什么好处吗?
code
try
{
code that might throw an anticipated exception you want to handle
}
catch
{
}
code
try
{
code that might throw an anticipated exception you want to handle
}
catch
{
}
code
更新:
我最初问这个问题时是否引用了C#,但正如A. Levy所评论的那样,它可以应用于任何异常处理语言,因此我使标记反映了这一点。