Skip to main content

Elliotte Rusty Harolde - Tip: When you can't throw an exception

Elliotte Rusty Harolde provides a Tip: When you can't throw an exception:

One problem with checked exceptions is that sometimes you simply aren't allowed to throw them. In particular, if you are overriding a method declared in a superclass or implementing a method declared in an interface, and that method does not declare any checked exceptions, your implementation can't declare one either. This forces you to handle the exception prematurely. You can convert the exception to a run-time exception, or you can suppress it without handling it. But is this what you should be doing, or is something more deeply wrong here? ...

Community: General