I’m creating a general class that accepts as a parameter a list of exceptions it is willing to handle.
public class MyClass {
public MyClass (List<Class<? extends RuntimeException>> exceptions) ...
public execute() {
try {
justObj.call()
} catch(RuntimeException e) {
if exceptions.contains(e.getClass()) {...}
else {throw e;}
}
I want the thrown exception to be the original one I caught, e.g. if it was NullPointerException then I want the throw to be NullPointerException and not RuntimeException as it now.
Any idea how to achieve it ?
It works already:
throws: