|
|
|
|
|
by paulddraper
2380 days ago
|
|
99% of the time I want to do the same thing for IOException as I would for NoSuchElementException or a DOMException. That said, even if typed checked exception handling is important...it quickly becomes untenable. Thing thing = create();
try {
...
} finally {
cleanup(thing);
}
You might try to abstract this withThing(thing -> ...)
But what if "..." potentially throws IOException? What if it potentially throws IOException or AWTException?You have to give up all your exception type safety to make an abstraction like withThing. It's just not composable. |
|
For one level deep callbacks (for resource handling and the like) it works reasonably well though.