fix: better "server add" failure

See toolshed/organising#570
This commit is contained in:
2024-12-28 21:17:51 +01:00
parent 27f68b1dc5
commit 3f32dbb1a3
2 changed files with 13 additions and 11 deletions

View File

@ -9,12 +9,11 @@ import (
func EnsureIPv4(domainName string) (string, error) {
ipv4, err := net.ResolveIPAddr("ip4", domainName)
if err != nil {
return "", fmt.Errorf("unable to resolve ipv4 address for %s, %s", domainName, err)
return "", fmt.Errorf("%s: unable to resolve IPv4 address: %s", domainName, err)
}
// NOTE(d1): e.g. when there is only an ipv6 record available
if ipv4 == nil {
return "", fmt.Errorf("unable to resolve ipv4 address for %s", domainName)
return "", fmt.Errorf("%s: no IPv4 available", domainName)
}
return ipv4.String(), nil