I'm thinking of implementing better ways of error handling through exceptions. When I'm deep in my code and want to return an error, I have two options:
- Throw an exception that extends runtime exception.
- Pass error message objects along with my response. This allows each level to handle an error if needed by looking at the error message.
I like 1. However, let's say I create an interface:
public interface Interface {
method1();
method2();
}
Now, in this type of contract, I haven't seen interfaces that declare the methods as:
method1() throws ExtendedRuntimeException;
method2() throws ExtendedRuntimeException;
What is a cleaner way of specifying that the implemetation needs to handle the extended runtime exception?