▲ | xmodem 2 days ago | |
Part of it is an ecosystem thing. It's a lot better now, but there were times when libraries would throw a variety of checked exceptions that usually couldn't be handled sensibly other than by being caught and logged by your top-level exception handler. This forced you to either (a) pollute many methods on many layers of your class hierarchy with `throws X`, potentially also polluting your external API (b) catch, wrap and re-throw the checked exception at every call site that could throw it (c) Use Lombok's `@SneakyThrows` to convert a checked exception into an unchecked one. Which they advise against using on production code, and which I have definitely never used on production code. There are specific situations where checked exceptions work well - where you want to say to specific code "I can fail in this specific way, and there is something sensible you can do about it". But those are fairly rare in my experience. |