Skip to content

Commit

Permalink
Prevent blaze from crashing on invalid resource locations.
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 176659616
  • Loading branch information
corbinrsmith-work authored and Copybara-Service committed Nov 22, 2017
1 parent 3948159 commit 69cb005
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,20 @@ private static PathFragment addResourceDir(
PathFragment packageFragment =
file.getArtifactOwner().getLabel().getPackageIdentifier().getSourceRoot();
PathFragment packageRelativePath = file.getRootRelativePath().relativeTo(packageFragment);
resourceRoots.add(
trimTail(file.getExecPath(), makeRelativeTo(resourceDir, packageRelativePath)));

try {
resourceRoots.add(
trimTail(file.getExecPath(), makeRelativeTo(resourceDir, packageRelativePath)));
} catch (IllegalArgumentException e) {
ruleErrorConsumer.attributeError(
resourcesAttr,
String.format(
"'%s' (generated by '%s') is not under the directory '%s' (derived from %s).",
file.getRootRelativePath(),
file.getArtifactOwner().getLabel(),
packageRelativePath,
file.getRootRelativePath()));
throw new RuleErrorException();
}
return resourceDir;
}

Expand Down

0 comments on commit 69cb005

Please sign in to comment.