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
This commit is contained in:
Cole Faust 2024-05-09 15:50:50 -07:00
parent 5bc2b73593
commit fa652f4714

View file

@ -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
}