From eabfb2abf7aefb9aa6c4462cc442e2f12ecc51c9 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 23 Dec 2022 09:13:20 +0100 Subject: [PATCH] Report `AspectCreationException` to the user Since ec4be003ec328ca593e93a724947259a5330a476, `AspectCreationException`s were 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 --- .../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()));