Suppose I have a method or a constructor that uses another method or constructor internally that declares a RuntimeException can be thrown.
// Example:
public MyClass(Object arg) {
setVar(arg);
// Not responsible for dealing with the exception
}
public void setVar(Object arg) throws MyRuntimeException {
if(!isValidArg(arg))
throw new MyRuntimeException("Got you, evil argument!");
// Do something
}
In this case the RuntimeException is thrown if for example necessary preconditions are not fulfilled.
Q: Should the wrapping method/constructor declare the same Exception, if it's argument could cause the Exception to be thrown?