显示抛出异常的所有函数 [英] Show all functions that throw exceptions

查看:138
本文介绍了显示抛出异常的所有函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个Java程序,我想知道Eclipse中是否有一些工具会指出抛出异常的所有方法。我只想确保我得到了所有的。



感谢您的帮助,



Dan

解决方案

检查异常必须被捕获,所以Eclipse会告诉你有关它们。另一方面,未检查的异常(也称为 RuntimeException )是不应该发生的,它的大部分时间是编程问题。因此,Java不需要抓住它们,AFAIK Eclipse将不会显示任何提示,告诉您一个潜在的问题(可能更好的可见性)。



您可以阅读 未经检查的例外 - 争议 ,一篇文章,Oracle提供了关于未选中的异常的状态。



如果你想自己建立一些东西,看看直接已知子类 RuntimeException ,它将帮助您识别可以抛出的异常,而不会被捕获。


I am working on a Java program and I was wondering if there was some tool in Eclipse that would point out all of the methods that throw exceptions. I just want to make sure that I got all of them.

Thanks for the help,

Dan

解决方案

Checked exception must be caught so Eclipse will tell you about them. On the other hand unchecked exception (aka RuntimeException) are "not supposed to happen", it's most of the time a programming problem. Hence Java doesn't require to catch them and AFAIK Eclipse will not display any hints to tell you about a potential issue (it's probably better for visibility).

You can read Unchecked Exceptions — The Controversy, an article where Oracle gives its state of mind about unchecked exceptions.

If you want to build something yourself, look the Direct Known Subclasses of RuntimeException, it will help you to identify exceptions that can be thrown without being caught.

这篇关于显示抛出异常的所有函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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