fix(repo/common): improve MapGetKV not found error
Kyle Huntsman committed
Mar 7, 2022 at 17:00 UTC
a09b6c205eea1ecaaae1e9ba0b45e4a091308694
1 file changed
+7
-1
repo/common/common.go
+7
-1
@@ -21,7 +21,13 @@ func MapGetKV(v map[string]interface{}, key string) (interface{}, error) {
21
22
cursor, ok = mcursor[part]
23
if !ok {
24
- return nil, fmt.Errorf("%s key has no attributes", sofar)
24
+ // Construct the current path traversed to print a nice error message
25
+ var path string
26
+ if len(sofar) > 0 {
27
+ path += sofar + "."
28
+ }
29
+ path += part
30
+ return nil, fmt.Errorf("%s not found", path)
31
}
32
}
33
return cursor, nil