From fa652f47143daa7ff3506e5c5a36a9d29105ec23 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 9 May 2024 15:50:50 -0700 Subject: [PATCH] Fix error message when a select condition isn't handled Preivously it attempted to print all conditions and their values, but that doesn't tell you which one was wrong, and the formatting was all weird due to trying to print complex go types. Bug: 323382414 Test: m nothing --no-skip-soong-tests Change-Id: If9653796f5e9139c0b4a7843b441eb0409967b55 --- proptools/configurable.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proptools/configurable.go b/proptools/configurable.go index 06b39a5..cfb2f84 100644 --- a/proptools/configurable.go +++ b/proptools/configurable.go @@ -439,6 +439,7 @@ func (c *singleConfigurable[T]) evaluateNonTransitive(propertyName string, evalu values[i] = evaluator.EvaluateConfiguration(condition, propertyName) } foundMatch := false + nonMatchingIndex := 0 var result *T for _, case_ := range c.cases { allMatch := true @@ -449,6 +450,7 @@ func (c *singleConfigurable[T]) evaluateNonTransitive(propertyName string, evalu } if !pat.matchesValue(values[i]) { allMatch = false + nonMatchingIndex = i break } } @@ -460,7 +462,8 @@ func (c *singleConfigurable[T]) evaluateNonTransitive(propertyName string, evalu if foundMatch { return result } - evaluator.PropertyErrorf(propertyName, "%s had value %s, which was not handled by the select statement", c.conditions, values) + + evaluator.PropertyErrorf(propertyName, "%s had value %s, which was not handled by the select statement", c.conditions[nonMatchingIndex].String(), values[nonMatchingIndex].String()) return nil }