Better error reporting

This commit is contained in:
Bryan Boreham committed 2014-10-14 16:59:00 +01:00
1 parent 6d32ac80b7
commit 4709f852c3
1 file changed
+4 -3
+4 -3
View File
@@ -34,10 +34,11 @@ func (ops LookupError) Error() string {
type DuplicateError struct { type DuplicateError struct {
Name string Name string
WeaveIp net.IP WeaveIp net.IP
Ident string
} }
func (err DuplicateError) Error() string { func (err DuplicateError) Error() string {
return "Duplicate " + err.Name + "," + err.WeaveIp.String() return "Duplicate " + err.Name + "," + err.WeaveIp.String() + " in container " + err.Ident
} }
// Stop gap. // Stop gap.
@@ -70,8 +71,8 @@ func (zone *ZoneDb) AddRecord(identifier string, name string, ip net.IP, weave_i
zone.mx.Lock() zone.mx.Lock()
defer zone.mx.Unlock() defer zone.mx.Unlock()
fqdn := dns.Fqdn(name) fqdn := dns.Fqdn(name)
if zone.indexOfNameAddr(fqdn, weave_ip) != -1 { if index := zone.indexOfNameAddr(fqdn, weave_ip); index != -1 {
return DuplicateError{fqdn, weave_ip} return DuplicateError{fqdn, weave_ip, zone.recs[index].Ident}
} }
zone.recs = append(zone.recs, Record{identifier, fqdn, ip, weave_ip, weave_subnet}) zone.recs = append(zone.recs, Record{identifier, fqdn, ip, weave_ip, weave_subnet})
return nil return nil