From 15ae23e84d7e686a673a8d9c7122520aa71ded1a Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 9 Jan 2023 20:53:21 -0800 Subject: [PATCH] Report `AspectCreationException` to the user 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 --- .../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 d32d5dafc919c2..dd40a155409ef8 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 @@ -465,6 +465,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()));