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:
parent
3e2db5c10b
commit
973c907708
|
@ -713,9 +713,11 @@ func (b baseTestingComponent) newTestingBuildParams(bparams BuildParams) Testing
|
||||||
|
|
||||||
func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuildParams, []string) {
|
func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuildParams, []string) {
|
||||||
var searchedRules []string
|
var searchedRules []string
|
||||||
for _, p := range b.provider.BuildParamsForTests() {
|
buildParams := b.provider.BuildParamsForTests()
|
||||||
searchedRules = append(searchedRules, p.Rule.String())
|
for _, p := range buildParams {
|
||||||
if strings.Contains(p.Rule.String(), rule) {
|
ruleAsString := p.Rule.String()
|
||||||
|
searchedRules = append(searchedRules, ruleAsString)
|
||||||
|
if strings.Contains(ruleAsString, rule) {
|
||||||
return b.newTestingBuildParams(p), searchedRules
|
return b.newTestingBuildParams(p), searchedRules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -725,7 +727,7 @@ func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuil
|
||||||
func (b baseTestingComponent) buildParamsFromRule(rule string) TestingBuildParams {
|
func (b baseTestingComponent) buildParamsFromRule(rule string) TestingBuildParams {
|
||||||
p, searchRules := b.maybeBuildParamsFromRule(rule)
|
p, searchRules := b.maybeBuildParamsFromRule(rule)
|
||||||
if p.Rule == nil {
|
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
|
return p
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue