Simplify try catch block
<dependency>
<groupId>com.github.vgalloy</groupId>
<artifactId>auto-catch</artifactId>
<version>1.2.0</version>
</dependency>
Callable wrapping:
try {
Thread.sleep(1_000);
} catch (final InterruptedException e) {
throw new RuntimeException(e);
}
With Auto catch :
AutoCatch.autoCatch(() -> Thread.sleep(1_000));
Supplier wrapping:
final File file = new File("test");
final String canonicalName;
try {
canonicalName = file.getCanonicalPath();
} catch (final IOException e) {
throw new RuntimeException(e);
}
With Auto catch :
final File file = new File("test");
final String canonicalName = AutoCatch.autoCatch(file::getCanonicalPath);