A collection of helper methods for dealing with exceptions in Java 8.
The scope of Fishbowl is divided into four sections.
There are two options if a statement inside of a method (may) throw a
checked exception that cannot be handled reasonably. The exception can be
rethrown and the caller of the current method has to handle it or it can
be wrapped with a RuntimeException. Use Fishbowl's method
wrapCheckedException
for doing this with a single line of
code.
Sometimes exceptions are best handled by returning a default
value. This can be done by a single line of code with
defaultIfException
.
Sometimes it is appropriate to continue if a void method fails. This can be easily done with ignoreException
.
Fishbowl makes it possible to use the AAA (Arrange-Act-Assert) pattern for writing tests for code that throws an exception. For that purpose it exposes the exception so that it can be checked by any assertion library.