Throwing a NPE yourself? There must be a better solution....+ + // fail fast if the defining parent could not be found due to a bug in the rule + if ( parent == null ) + { + throw new NullPointerException( "failed to find parent POM which defines the current rule" ); + }
This code is originally from me, so I'll explain. If the rule fails to find the parent this is due to an error in the rule code. The explicit check makes it easier to diagnose. Without it, a NPE will be thrown later when the parent value is needed. This is not always the case: without the explicit check the plugin execution will succeed when used in the parent POM, but fail with a NPE in the child POM which inherits the configuration.
It is debatable whether NullPointerException is a good choice, but I think none of the other standard RuntimeExceptions are a better fit. I also didn't want to use EnforcerRuleException, because the NPE is an internal error, not an expected result of the rule configuration / execution.
Cheers Michael Koch --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
