如何防止嵌套异常中的Java导航

时间:2017-12-27 06:09:52

标签: java exception

在Java中的嵌套异常中,嵌套的Exception总是转到父类,因此它会发生两次,并且初始异常下面的代码会发生 永远不会被执行 如何在C#中预防它?

try
{
    try
    {

    }
    catch(Exception ex)
    {
        // Excep  goes to parent Exception try catch
    }        

    The code here is never executes

}
catch(Exception ex)
{

}

1 个答案:

答案 0 :(得分:-1)

这可以解决您的问题:    尝试    {       尝试       {

  }
  catch(Exception ex)
  {
      // Excep  goes to parent Exception try catch
  }        
  finally
  {
        The code here is never executes
   }
}
catch(Exception ex)
{

}