Closed akopper closed 3 years ago
Yes, this is mentioned in the Javadocs, ex: https://failsafe-lib.github.io/javadoc/net/jodah/failsafe/FailsafeExecutor.html#get-net.jodah.failsafe.function.CheckedSupplier-
As for why things work this way, it was a design decision to wrap checked exceptions from user-supplied synchronously executed code. The alternative would have been for FailsafeExecutor.get
to declare throws Exception
, which would require all calling code to handle checked exceptions, whether they're likely to be thrown or not. Yet another alternative would have been to use the sneaky throws hack to throw checked exceptions without declaring them, but that may be somewhat surprising for users.
Exceptions not inheriting from RuntimeException or Error are wrapped in FailsafeException
Consider the following
The result will be:
I would expect java.lang.Exception: Custom Exception to be the outermost Exception.
This behaviour can be traced back to https://github.com/jhalterman/failsafe/blob/f9ddba08a7b218c0f14dc8f713709b2e28aeab65/src/main/java/net/jodah/failsafe/FailsafeExecutor.java#L379-L383
Is there a reason for this?