From ea49dd44bc2ee3d611b6738f945fc0ea3f380fbf Mon Sep 17 00:00:00 2001 From: kshyanashree <109167932+kshyanashree@users.noreply.github.com> Date: Fri, 20 Jan 2023 00:15:59 -0800 Subject: [PATCH] Report `AspectCreationException` to the user (#17275) Since ec4be003ec328ca593e93a724947259a5330a476, `AspectCreationException`s are no longer reported to the user, resulting in error messages such as: ``` ERROR: Analysis of target '//pkg:foo' failed; build aborted: ``` With this commit, the error looks like this instead: ``` ERROR: Evaluation of aspect //aspects:aspects.bzl%my_aspect on //pkg:foo failed: ``` Context: https://github.com/bazelbuild/bazel-central-registry/pull/327 Closes #17071. PiperOrigin-RevId: 500883551 Change-Id: Iaf3b1dff8cb0915dd1ddc51d1d5e6578ff44029b Co-authored-by: Fabian Meumertzheim --- .../devtools/build/lib/skyframe/ConfiguredTargetFunction.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java index 7193f82b038d8a..dca55e0a094f0c 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java @@ -464,6 +464,10 @@ public SkyValue compute(SkyKey key, Environment env) } throw new ReportedException(e); } catch (AspectCreationException e) { + if (!e.getMessage().isEmpty()) { + // Report the error to the user. + env.getListener().handle(Event.error(null, e.getMessage())); + } throw new ReportedException( new ConfiguredValueCreationException( targetAndConfiguration, e.getMessage(), e.getCauses(), e.getDetailedExitCode()));