~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-15 07:44:56 UTC
  • mfrom: (3180.1.3 smart-tcp-unknown-host)
  • Revision ID: pqm@pqm.ubuntu.com-20080115074456-0v1w54h783oq7n48
(andrew) Don't traceback on host name errors when connecting to
        bzr:// URLs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
545
545
            port = BZR_DEFAULT_PORT
546
546
        else:
547
547
            port = int(self._port)
548
 
        result = self._socket.connect_ex((self._host, port))
549
 
        if result:
 
548
        try:
 
549
            self._socket.connect((self._host, port))
 
550
        except socket.error, err:
 
551
            # socket errors either have a (string) or (errno, string) as their
 
552
            # args.
 
553
            if type(err.args) is str:
 
554
                err_msg = err.args
 
555
            else:
 
556
                err_msg = err.args[1]
550
557
            raise errors.ConnectionError("failed to connect to %s:%d: %s" %
551
 
                    (self._host, port, os.strerror(result)))
 
558
                    (self._host, port, err_msg))
552
559
        self._connected = True
553
560
 
554
561
    def _flush(self):