Skip to content

Commit

Permalink
Report meaningful message when both --enable_workspace and --enable_b…
Browse files Browse the repository at this point in the history
…zlmod are false

WorkspaceNameFunction is the first one to fail when those two flags are off.

Working towards: #23023

PiperOrigin-RevId: 656006850
Change-Id: I4f7dda4cc3c2b19085d22490fd457fc53f267ed6
  • Loading branch information
meteorcloudy authored and copybara-github committed Jul 25, 2024
1 parent d915b98 commit 3f9fb7f
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ public SkyValue compute(SkyKey skyKey, Environment env)
}
Package externalPackage = externalPackageValue.getPackage();
if (externalPackage.containsErrors()) {
throw new WorkspaceNameFunctionException();
throw new WorkspaceNameFunctionException("Failed to load the WORKSPACE file");
}
return WorkspaceNameValue.withName(externalPackage.getWorkspaceName());
}
throw new WorkspaceNameFunctionException();
throw new WorkspaceNameFunctionException(
"Both --enable_bzlmod and --enable_workspace are disabled, but one of them must be enabled"
+ " to fetch external dependencies.");
}

private static class WorkspaceNameFunctionException extends SkyFunctionException {
WorkspaceNameFunctionException() {
WorkspaceNameFunctionException(String message) {
super(
new BuildFileContainsErrorsException(LabelConstants.EXTERNAL_PACKAGE_IDENTIFIER),
new BuildFileContainsErrorsException(LabelConstants.EXTERNAL_PACKAGE_IDENTIFIER, message),
Transience.PERSISTENT);
}
}
Expand Down

0 comments on commit 3f9fb7f

Please sign in to comment.