我试图弄清楚我的书中的代码示例是什么.它说
在外部异常处理程序的
try-catch块中添加内部块finally以防止丢失异常信息:
private void PreventLossOfExeptionFormat()
{
try
{
// ...
}
catch(Exception e)
{
Console.WriteLine("Error message == " + e.Message);
throw;
}
finally
{
try
{
// ...
}
catch(Exception e)
{
Console.WriteLine("An unexpected error occured in the finally block. Error message: " + e.Message);
}
}
}
Run Code Online (Sandbox Code Playgroud)
外部异常如何进入内部异常?据我所知,在外部catch块它越来越扔进finally块,但它然后得到立即陷入catch了的finally块或什么点try里面呢?因为如果已经有异常提出那么就没有try...
小智 7
外部异常如何进入内部异常?
它不是.
据我所知,在外部catch块中它被抛入finally块
是.
因为如果已经提出异常,那么就没有什么可试的了
你好像忽略了什么是明显的阅读.外部的try try catch最终用于捕获您标记为的行中的异常
// ...
也就是说,最后我想做的事情可能是他自己的例外.
| 归档时间: |
|
| 查看次数: |
58 次 |
| 最近记录: |