I was just wondering, is there another way around this issue?
Your idea is perfectly fine. Using own classes for try-catch
nested in a catch
or finally
statement is a common practice. In larger applications such constructs are almost unavoidable.
Your class could look like this:
class MyExecutionException extends MyLogicException {
//what happened in the first place
Throwable getOriginException();
// what have we tried?
Throwable getRecoveryException();
// more than 1 thing can happen in recovery, order is important, hence list
List<Throwable> getAllExceptions();
}
Such approach lets you have all the information in one place and makes implementing a single place for exception handling and logging very easy. Just make sure you make your exception wrapper/container class as versatile as possible to suit your future needs.