I would rather not add/remove throws clauses manually, especially while prototyping. Is there a batch refactoring tool that adds/removes throws clauses to every method to reflect the code? After all, the compiler tells you what exceptions a method may throw, therefore maybe a tool exists that uses that information to manipulate throws clauses.
EDIT: Before I clarified that I am looking for a batch tool, somebody has mentioned a manual intervention via IDE, but this is not what I am looking for. I am looking for a batch utility.
ProjectLombok has a wonderful feature called SneakyThrows (It may fit your use case in prototyping.)
From their website you can do the following without a compile error :
@SneakyThrows(UnsupportedEncodingException.class)
public String utf8ToString(byte[] bytes) {
return new String(bytes, "UTF-8");
}
@SneakyThrows
public void run() {
throw new Throwable();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With