err creates and returns an error for the current object, field name and with the specified message
(am map[string]interface{}, fname, msg string)
| 1106 | |
| 1107 | // err creates and returns an error for the current object, field name and with the specified message |
| 1108 | func (b *Builder) err(am map[string]interface{}, fname, msg string) error { |
| 1109 | |
| 1110 | // Get path of objects till the error |
| 1111 | names := []string{} |
| 1112 | var name string |
| 1113 | for { |
| 1114 | if v := am[AttribName]; v != nil { |
| 1115 | name = v.(string) |
| 1116 | } else { |
| 1117 | name = "?" |
| 1118 | } |
| 1119 | names = append(names, name) |
| 1120 | var par interface{} |
| 1121 | if par = am[AttribParentInternal]; par == nil { |
| 1122 | break |
| 1123 | } |
| 1124 | am = par.(map[string]interface{}) |
| 1125 | } |
| 1126 | path := []string{} |
| 1127 | for i := len(names) - 1; i >= 0; i-- { |
| 1128 | path = append(path, names[i]) |
| 1129 | } |
| 1130 | |
| 1131 | return fmt.Errorf("Error in object:%s field:%s -> %s", strings.Join(path, "/"), fname, msg) |
| 1132 | } |
| 1133 | |
| 1134 | // debugPrint prints the internal attribute map of the builder for debugging. |
| 1135 | // This map cannot be printed by fmt.Printf() because it has cycles. |
no outgoing calls
no test coverage detected