Let’s look at a widely used, still controversial feature of Project Lombok that allows you to magically get rid of a checked exception.

Java is the only programming language in the world that has checked exceptions, which forces the caller to know about the individual exception types thrown by the called function.

What do you do when you face a checked exception? As we will see in a later blog post, propagating checked exceptions through your code is both leaking implementation details, annoying, and even dangerous. That’s why in the vast majority of cases you should catch-rethrow it as a runtime exception, and let it “silently” terminate your current use-case.

#java #best practices #clean code #exception #lombok #exception handling in java

Hide Checked Exceptions With SneakyThrows
1.40 GEEK