My function looks like:
void Foo() throws Exception {
...
}
I'm then calling this method in other method's parameter:
Bar( () -> Foo());
And Bar() looks like this:
void Bar(Runnable method) {
try {
method.run()
} catch (Exception e) {
...
}
}
Earlier I had Foo() throwing RuntimeException so it worked, but when i changed it to throw Exception compiler won't allow me to run my code indicating its uncaught exception. I have to use checked exception so going back to Runtime is not an option.
SOLUTION based on this solution Java 8 Lambda function that throws exception? I have used try catch block in this call
Bar( () -> { try { Foo(); } catch (Exception e) { }; } );
Thanks for help anyway