Improve dial error messages
@@ -290,6 +290,9 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
that we previously had (halting a dial when we run out of addrs)
*/
goodAddrs := s.filterKnownUndialables(s.peers.Addrs(p))
+ if len(goodAddrs) == 0 {
+ return nil, errors.New("no good addresses")
+ }
goodAddrsChan := make(chan ma.Multiaddr, len(goodAddrs))
for _, a := range goodAddrs {
goodAddrsChan <- a
@@ -352,7 +355,7 @@ func (s *Swarm) dialAddrs(ctx context.Context, p peer.ID, remoteAddrs <-chan ma.
// use a single response type instead of errs and conns, reduces complexity *a ton*
respch := make(chan dialResult)
- defaultDialFail := fmt.Errorf("failed to dial %s (default failure)", p)
+ defaultDialFail := inet.ErrNoRemoteAddrs
exitErr := defaultDialFail
defer s.limiter.clearAllPeerDials(p)
