How to avoid repeating complex exception handling code in a wrapper class?

Viewed 651

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?

2 Answers
Related