Let's say I have this interface A, which is implemented by several providers:
interface A
{
void x();
void y();
}
However, I want providers to be able to throw exceptions to signal that something is not working, and maybe the method might call RuntimeException. In each case, the code that calls these methods must handle the failure and continue. Just because 1 provider drops NPE, I don't want the system to crash. Instead of leaving this to the person calling the method (or, indeed, keeping the line), I would like to make sure that every call will catch all exceptions, declaring each method as:
void x() throws Exception;
but this is usually a bad practice (PMD is not like and usually I agree with the rule for specific methods), so I wonder if this is an exception to the rule or is there a better way?
Let me clarify that I'm looking for a solution in which the calling interface is forced to handle all exceptions (including RuntimeExceptions).
, OSGi. , OSGi , . , , - OSGi, . , , NPE . , , , .