chore: simplify some error prompt

This commit is contained in:
mzz2017 2023-02-15 23:06:44 +08:00
parent 6b68e74335
commit b767036966

View File

@ -463,8 +463,11 @@ func (d *Dialer) Check(timeout time.Duration,
} else {
// Append timeout if there is any error or unexpected status code.
if err != nil {
if strings.Contains(err.Error(), "network is unreachable") {
if strings.HasSuffix(err.Error(), "network is unreachable") {
err = fmt.Errorf("network is unreachable")
} else if strings.HasSuffix(err.Error(), "no suitable address found") ||
strings.HasSuffix(err.Error(), "non-IPv4 address") {
err = fmt.Errorf("IPv%v is not supported", opts.networkType.IpVersion)
}
d.Log.WithFields(logrus.Fields{
"network": opts.networkType.String(),