如果两个渔获物和finally块抛出的异常会发生什么事?
What happens if both catch and finally blocks throw exception?
在最后
块抛出一个异常,这将有效地隐藏除了从抓块将是一个最终抛出。它要么抓时记录异常,或确保finally块本身不抛出异常,因此重要的,否则你可以得到抛出异常被扼杀了,从来没有见过。
When the finally
block throws an exception, it will effectively hide the exception thrown from the catch
block and will be the one ultimately thrown. It is therefore important to either log exceptions when caught, or make sure that the finally block does not itself throw an exception, otherwise you can get exceptions being thrown that are stifled and never seen.
上一篇:动态创建℃的对象;类型>对象、类型、动态、GT
下一篇:静态终结静态