Dealing with checked exceptions#
When implementing your reactive pipeline, you write lots of functions (
java.util.function.Function), consumers (
java.util.function.Consumer), suppliers (
java.util.function.Supplier) and so on.
By default, you cannot throw checked exceptions.
When integrating libraries throwing checked exceptions (like
IOException) it’s not very convenient to add a
try/catch block and wrap the thrown exception into a runtime exception:
Mutiny provides utilities to avoid having to do this manually.
If your operation throws a checked exception, you can use the
For example, if your synchronous transformation uses a method throwing a checked exception, wrap it using
You can add the following import statement to simplify the usage of the provided methods:
import static io.smallrye.mutiny.unchecked.Unchecked.*;