Refactor DependencyResolver to collect and return loading errors.
This should never be triggered in production, where we always run a loading
phase first and only analyze targets that load successfully. I.e., this is
just plumbing which will be hooked up in a subsequent change.
--
MOS_MIGRATED_REVID=113258593
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index d409560..403528e 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -804,6 +804,11 @@
}
@Override
+ protected void missingEdgeHook(Target from, Label to, NoSuchThingException e) {
+ // The error must have been reported already during analysis.
+ }
+
+ @Override
protected Target getTarget(Label label) {
if (targetCache == null) {
try {
@@ -858,12 +863,19 @@
class SilentDependencyResolver extends DependencyResolver {
@Override
protected void invalidVisibilityReferenceHook(TargetAndConfiguration node, Label label) {
- // The error must have been reported already during analysis.
+ throw new RuntimeException("bad visibility on " + label + " during testing unexpected");
}
@Override
protected void invalidPackageGroupReferenceHook(TargetAndConfiguration node, Label label) {
- // The error must have been reported already during analysis.
+ throw new RuntimeException("bad package group on " + label + " during testing unexpected");
+ }
+
+ @Override
+ protected void missingEdgeHook(Target from, Label to, NoSuchThingException e) {
+ throw new RuntimeException(
+ "missing dependency from " + from.getLabel() + " to " + to + ": " + e.getMessage(),
+ e);
}
@Override