Better exception handling in _connect()