Allow use of Exceptions to exit early out of configured-target creation, instead of passing and checking null in all helpers.
Demonstrates this pattern usage in a few select rules (e.g. AndroidBinary) where this was particularly egregious.
There are many places which can benefit from this pattern -- this change doesn't try to fix them all at once.
--
MOS_MIGRATED_REVID=123012378
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index f01026b..78ec863 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -183,8 +183,18 @@
public interface ConfiguredTargetFactory<TConfiguredTarget, TContext> {
/**
* Returns a fully initialized configured target instance using the given context.
+ *
+ * @throws RuleErrorException if configured target creation could not be completed due to rule
+ * errors
*/
- TConfiguredTarget create(TContext ruleContext) throws InterruptedException;
+ TConfiguredTarget create(TContext ruleContext) throws InterruptedException, RuleErrorException;
+
+ /**
+ * Exception indicating that configured target creation could not be completed. Error messaging
+ * should be done via {@link RuleErrorConsumer}; this exception only interrupts configured
+ * target creation in cases where it can no longer continue.
+ */
+ public static final class RuleErrorException extends Exception {}
}
/**