com.chutneytesting.tools.ui.ThrowingConsumer Maven / Gradle / Ivy
package com.chutneytesting.tools.ui;
import java.util.function.Consumer;
/**
* Version of the {@link Consumer} able to throw Checked {@link Exception Exceptions}.
*/
@FunctionalInterface
public interface ThrowingConsumer {
void accept(T t) throws Exception;
/**
* @param throwing the {@link ThrowingConsumer} to convert to {@link Consumer}
* @param errorHandler used when an {@link Exception} is raised by the given {@link ThrowingConsumer}
*/
static Consumer silent(ThrowingConsumer throwing, Consumer errorHandler) {
return t -> {
try {
throwing.accept(t);
} catch (Exception e) {
errorHandler.accept(e);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy