I am trying to catch a specific runtime exception (so not throwable) and just log it (log.error has a void return type). What is the simplest way to do this in vavr?
try {
sayHello();
} catch (MyAppRuntimeException ex) {
log.error("Error occured") // log.error returns void not Void so I couldn't find a suitable method in Vavr library
}
I have tried
Try.run(() -> sayHello())
.recover(MyAppRuntimeException.class, ex->log.error("Error occured: {}", ex.getMessage()))
I get:
Bad return type void cannot be converted to Void
If .recover is not the right method please suggest alternatives where I can catch my one specific Exception but not Throwable since it catches all exceptions and errors.