4 ms·
IMO almost all of the problems people have in practice with checked exceptions are from poor API design rather than an issue with checked exceptions themselves.
by jsankey 17y ago
IMO almost all of the problems people have in practice with checked exceptions are from poor API design rather than an issue with checked exceptions themselves. The core Java APIs use checked exceptions for too many conditions which are not recoverable - causing a whole bunch of maintenance pain for no benefit. This is understandable considering that Java was the first mainstream language to really exercise the concept.
If used judiciously, I think checked exceptions do have benefits. There are classes of errors that are exceptional but also conceivably recoverable. The fact that they are exceptional means it is important to draw attention to them (they may otherwise be overlooked). The fact that they are recoverable justifies requiring calling code to make a choice - handle or propagate the error. Even in these cases, the code can get messy, but I see that as a fact of life: writing robust code isn't easy.