Improve error reporting when a rule cannot be found

Outputs the list of available rules on separate lines.

Bug: 179354495
Test: m nothing
Merged-In: I845064e032f0a47d00883ff775c4f7b4fee7631e
Change-Id: I845064e032f0a47d00883ff775c4f7b4fee7631e
(cherry picked from commit 4dbf6cfbaec8b6ce7c6638cd455da89879d61d40)
This commit is contained in:
Paul Duffin 2021-06-08 10:06:37 +01:00
parent 3e2db5c10b
commit 973c907708
1 changed files with 6 additions and 4 deletions

View File

@ -713,9 +713,11 @@ func (b baseTestingComponent) newTestingBuildParams(bparams BuildParams) Testing
func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuildParams, []string) {
var searchedRules []string
for _, p := range b.provider.BuildParamsForTests() {
searchedRules = append(searchedRules, p.Rule.String())
if strings.Contains(p.Rule.String(), rule) {
buildParams := b.provider.BuildParamsForTests()
for _, p := range buildParams {
ruleAsString := p.Rule.String()
searchedRules = append(searchedRules, ruleAsString)
if strings.Contains(ruleAsString, rule) {
return b.newTestingBuildParams(p), searchedRules
}
}
@ -725,7 +727,7 @@ func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuil
func (b baseTestingComponent) buildParamsFromRule(rule string) TestingBuildParams {
p, searchRules := b.maybeBuildParamsFromRule(rule)
if p.Rule == nil {
panic(fmt.Errorf("couldn't find rule %q.\nall rules: %v", rule, searchRules))
panic(fmt.Errorf("couldn't find rule %q.\nall rules:\n%s", rule, strings.Join(searchRules, "\n")))
}
return p
}