Skip to content

Commit

Permalink
Simplify ConfiguredValueCreationException
Browse files Browse the repository at this point in the history
- Reduce excessive constructor overload
- Move withoutMessage() logic to the caller (where the intention is expressed).
- Replaced ConfiguredTargetFunctionException with ReportedException /
  UnreportedException to force explicit declaration of whether the error was
  directly reported in CTF.

PiperOrigin-RevId: 384235733
  • Loading branch information
gregestren authored and copybara-github committed Jul 12, 2021
1 parent 5709486 commit ec4be00
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 160 deletions.
17 changes: 16 additions & 1 deletion src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ java_library(
"SingleRunfilesSupplier.java",
"SourceManifestAction.java",
"StarlarkProviderValidationUtil.java",
"TargetAndConfiguration.java",
"TargetCompleteEvent.java",
"TargetContext.java",
"TopLevelArtifactHelper.java",
Expand Down Expand Up @@ -346,6 +345,7 @@ java_library(
":starlark/starlark_exec_group_collection",
":starlark/starlark_late_bound_default",
":starlark/starlark_toolchain_context",
":target_and_configuration",
":template_variable_info",
":test/analysis_failure",
":test/analysis_failure_info",
Expand Down Expand Up @@ -598,6 +598,7 @@ java_library(
":constraints/top_level_constraint_semantics",
":extra_action_artifacts_provider",
":make_environment_event",
":target_and_configuration",
":target_configured_event",
":test/coverage_report_action_factory",
":test/instrumented_files_info",
Expand Down Expand Up @@ -1033,6 +1034,20 @@ java_library(
],
)

java_library(
name = "target_and_configuration",
srcs = ["TargetAndConfiguration.java"],
deps = [
":config/build_configuration",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/concurrent",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_key",
"//third_party:guava",
"//third_party:jsr305",
],
)

java_library(
name = "target_configured_event",
srcs = ["TargetConfiguredEvent.java"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,7 @@ private ImmutableList<Dependency> resolveGenericTransition(
return null; // Need more Skyframe deps for a Starlark transition.
}
} catch (TransitionException e) {
throw new ConfiguredValueCreationException(
ctgValue.getTarget().getLocation(),
e.getMessage(),
ctgValue.getLabel(),
ctgValue.getConfiguration());
throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
}

if (depFragments.equals(getCurrentConfiguration().fragmentClasses())
Expand Down Expand Up @@ -258,11 +254,7 @@ private ImmutableList<Dependency> resolveGenericTransition(
configurationKeys.put(transitionKey, buildConfigurationValueKey);
}
} catch (OptionsParsingException e) {
throw new ConfiguredValueCreationException(
ctgValue.getTarget().getLocation(),
e.getMessage(),
ctgValue.getLabel(),
ctgValue.getConfiguration());
throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
}

Map<SkyKey, ValueOrException<InvalidConfigurationException>> depConfigValues =
Expand Down Expand Up @@ -294,11 +286,7 @@ private ImmutableList<Dependency> resolveGenericTransition(
return null; // Need dependency configurations.
}
} catch (InvalidConfigurationException e) {
throw new ConfiguredValueCreationException(
ctgValue.getTarget().getLocation(),
e.getMessage(),
ctgValue.getLabel(),
ctgValue.getConfiguration());
throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
}

return ImmutableList.sortedCopyOf(SPLIT_DEP_ORDERING, dependencies);
Expand Down Expand Up @@ -327,11 +315,7 @@ private ImmutableList<String> collectTransitionKeys(Attribute attribute)
return null; // Need more Skyframe deps for a Starlark transition.
}
} catch (TransitionException e) {
throw new ConfiguredValueCreationException(
ctgValue.getTarget().getLocation(),
e.getMessage(),
ctgValue.getLabel(),
ctgValue.getConfiguration());
throw new ConfiguredValueCreationException(ctgValue, e.getMessage());
}
if (!SplitTransition.equals(getCurrentConfiguration().getOptions(), toOptions.values())) {
return ImmutableList.copyOf(toOptions.keySet());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/query2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:inconsistent_aspect_order_exception",
"//src/main/java/com/google/devtools/build/lib/analysis:platform_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:required_config_fragments_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection",
"//src/main/java/com/google/devtools/build/lib/analysis:toolchain_context",
"//src/main/java/com/google/devtools/build/lib/buildeventstream",
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/google/devtools/build/lib/skyframe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:platform_options",
"//src/main/java/com/google/devtools/build/lib/analysis:resolved_toolchain_context",
"//src/main/java/com/google/devtools/build/lib/analysis:rule_configured_object_value",
"//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection",
"//src/main/java/com/google/devtools/build/lib/analysis:toolchain_context",
"//src/main/java/com/google/devtools/build/lib/analysis:top_level_artifact_context",
Expand Down Expand Up @@ -1228,7 +1229,7 @@ java_library(
srcs = ["ConfiguredValueCreationException.java"],
deps = [
":sane_analysis_exception",
"//src/main/java/com/google/devtools/build/lib/analysis:config/build_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:target_and_configuration",
"//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto",
"//src/main/java/com/google/devtools/build/lib/causes",
"//src/main/java/com/google/devtools/build/lib/cmdline",
Expand Down
Loading

0 comments on commit ec4be00

Please sign in to comment.