Java 8: Better exceptions

This post was originally published over at jooq.org as part of a special series
focusing on all things Java 8, including how take advantage of
lambda expressions, extension methods, and other great
stuff. You’ll find the
source code on GitHub.

So the above methods both assert that a given throwable is
thrown from a given runnable
– ThrowableRunnable to be precise, because
most functional interfaces, unfortunately, don’t allow for throwing
checked exceptions. See
this article for details.

Obviuously, these idioms aren’t necessarily more useful than an
actual try .. catch .. finally block,
specifically also because it does not support proper typing of
exceptions (at least not in this example), nor does it support the
try-with-resources statement.

Nonetheless, such utility methods will come in handy every now
and then.