5 ms·
This is especially true with Java 8's lambda syntax and method references. Because a Java function's signature includes its checked exceptions, implementing a
by etwigg 10y ago
This is especially true with Java 8's lambda syntax and method references. Because a Java function's signature includes its checked exceptions, implementing a functional interface can require lots of verbose nested try-catches.
e.g. rather than being able to write:
foodOnPlate.forEach(this::eat);
You end up having to write:
foodOnPlate.forEach(food -> {
try {
eat(food)
} catch (Barf e) {
// handle? rethrow as unchecked?
}
});
This library does a pretty god job handling that case:
https://github.com/diffplug/durian/blob/master/test/com/diffplug/common/base/ErrorsExample.java?ts=4 https://github.com/diffplug/durian/blob/master/test/com/diff...
- cbsmith 10y agoYeah, Durian pretty much saves my life.