Merge "Fix error message when a select condition isn't handled" into main

This commit is contained in:
Cole Faust 2024-05-22 18:51:10 +00:00 committed by Gerrit Code Review
commit 65e5724978

View file

@ -467,6 +467,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
@ -477,6 +478,7 @@ func (c *singleConfigurable[T]) evaluateNonTransitive(propertyName string, evalu
}
if !pat.matchesValue(values[i]) {
allMatch = false
nonMatchingIndex = i
break
}
}
@ -488,7 +490,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
}