Skip to content

vgalloy/autocatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Auto catch

Simplify try catch block

Maven

<dependency>
    <groupId>com.github.vgalloy</groupId>
    <artifactId>auto-catch</artifactId>
    <version>1.2.0</version>
</dependency>

Usage

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);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages