diff options
author | Nathan Harmata <nharmata@google.com> | 2016-01-29 23:03:03 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-02-01 09:45:55 +0000 |
commit | c1563c262e172bcf593b98eba35f1bb792f70766 (patch) | |
tree | 8703f6da466938ebef5bf4c46bc238037cec4256 /src/main/java/com/google/devtools/build/lib/packages | |
parent | 4be631ec58ad8aacec12c7bca76865ee63eb5669 (diff) |
Improve the error message on a missing implicit dep. The old error message didn't include the reason why the target was missing, and it also spammed Blaze users with a "tip" that's only relevant to Blaze developers debugging newly written integration tests.
--
MOS_MIGRATED_REVID=113401767
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java b/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java index b30c898e1c..470a11e2df 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java +++ b/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java @@ -235,18 +235,23 @@ public final class TargetUtils { // instanceof returns false if target is null (which is exploited here) if (target instanceof Rule) { Rule rule = (Rule) target; - return !isExplicitDependency(rule, label) - ? ("every rule of type " + rule.getRuleClass() + " implicitly depends upon the target '" - + label + "', but this target could not be found. " - + "If this is an integration test, maybe you forgot to add a mock for your new tool?") - : e.getMessage() + " and referenced by '" + target.getLabel() + "'"; + if (isExplicitDependency(rule, label)) { + return String.format("%s and referenced by '%s'", e.getMessage(), target.getLabel()); + } else { + // N.B. If you see this error message in one of our integration tests during development of + // a change that adds a new implicit dependency when running Blaze, maybe you forgot to add + // a new mock target to the integration test's setup. + return String.format("every rule of type %s implicitly depends upon the target '%s', but " + + "this target could not be found because of: %s", rule.getRuleClass(), label, + e.getMessage()); + } } else if (target instanceof InputFile) { return e.getMessage() + " (this is usually caused by a missing package group in the" + " package-level visibility declaration)"; } else { if (target != null) { - return "in target '" + target.getLabel() + "', no such label '" + label + "': " - + e.getMessage(); + return String.format("in target '%s', no such label '%s': %s", target.getLabel(), label, + e.getMessage()); } return e.getMessage(); } |