I have this class that wraps an object:
public class MyWrapper implements MyInterface { private MyInterface wrappedObj; public MyWrapper(MyInterface obj) { this.wrappedObj = obj; } @Override public String ping(String s) { return wrappedObj.ping(s); } @Override public String doSomething(int i, String s) { return wrappedObj.doSomething(i, s); } // many more methods ... } Now I want to add complex exception handling around the wrappedObj call.
It is the same for all the methods.
How do I avoid repeating the same exception handling code over and over?
private void handle(MyException exception)and call it from eachcatchblock?Object doWithExceptionHandling(Callable callable)