Raise an error instead of panic in SplitApexJarPairs.
Test: aosp_walleye-userdebug boots
Change-Id: I9a1c4ec5c8862b1936820b3cee6db9a85015cb0e
diff --git a/android/config.go b/android/config.go
index ee31c10..59118ce 100644
--- a/android/config.go
+++ b/android/config.go
@@ -897,27 +897,31 @@
}
// Expected format for apexJarValue = <apex name>:<jar name>
-func SplitApexJarPair(apexJarValue string) (string, string) {
- var apexJarPair []string = strings.SplitN(apexJarValue, ":", 2)
- if apexJarPair == nil || len(apexJarPair) != 2 {
- panic(fmt.Errorf("malformed apexJarValue: %q, expected format: <apex>:<jar>",
- apexJarValue))
+func SplitApexJarPair(ctx PathContext, str string) (string, string) {
+ pair := strings.SplitN(str, ":", 2)
+ if len(pair) == 2 {
+ return pair[0], pair[1]
+ } else {
+ reportPathErrorf(ctx, "malformed (apex, jar) pair: '%s', expected format: <apex>:<jar>", str)
+ return "error-apex", "error-jar"
}
- return apexJarPair[0], apexJarPair[1]
}
-func GetJarsFromApexJarPairs(apexJarPairs []string) []string {
+func GetJarsFromApexJarPairs(ctx PathContext, apexJarPairs []string) []string {
modules := make([]string, len(apexJarPairs))
for i, p := range apexJarPairs {
- _, jar := SplitApexJarPair(p)
+ _, jar := SplitApexJarPair(ctx, p)
modules[i] = jar
}
return modules
}
func (c *config) BootJars() []string {
- return append(GetJarsFromApexJarPairs(c.productVariables.BootJars),
- GetJarsFromApexJarPairs(c.productVariables.UpdatableBootJars)...)
+ ctx := NullPathContext{Config{
+ config: c,
+ }}
+ return append(GetJarsFromApexJarPairs(ctx, c.productVariables.BootJars),
+ GetJarsFromApexJarPairs(ctx, c.productVariables.UpdatableBootJars)...)
}
func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) {