aQute.lib.exceptions.RunnableWithException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.bndtools.templating.gitrepo Show documentation
Show all versions of org.bndtools.templating.gitrepo Show documentation
org.bndtools.templating.gitrepo
package aQute.lib.exceptions;
/**
* Runnable interface that allows exceptions.
*/
@FunctionalInterface
public interface RunnableWithException {
void run() throws Exception;
default Runnable orElseThrow() {
return () -> {
try {
run();
} catch (Exception e) {
throw Exceptions.duck(e);
}
};
}
default Runnable ignoreException() {
return () -> {
try {
run();
} catch (Exception e) {}
};
}
static Runnable asRunnable(RunnableWithException unchecked) {
return unchecked.orElseThrow();
}
static Runnable asRunnableIgnoreException(RunnableWithException unchecked) {
return unchecked.ignoreException();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy