如果两个渔获物和finally块抛出异常,会发生什么? [英] What happens if both catch and finally blocks throw exception?

查看:138
本文介绍了如果两个渔获物和finally块抛出异常,会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果两个渔获物和finally块抛出的异常会发生什么事?

What happens if both catch and finally blocks throw exception?

推荐答案

最后块抛出一个异常,这将有效地隐藏除了从<$ C抛出$ C>抓块将是一个最终抛出。它要么抓时记录异常,或确保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.

这篇关于如果两个渔获物和finally块抛出异常,会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆