Repository: conda/conda

Issue:
Whitespace in error messages
I started creating an environment then cancelled it. The error messages for the later commands have some extra vertical whitespace. Also, the "CondaValueError" part and "Value Error" parts seem like they shouldn't be included in the terminal output.

```
$conda create -n dot2tex python=2.7
CondaValueError: Value error: prefix already exists: /Users/aaronmeurer/anaconda/envs/dot2tex


$conda remove -n dot2tex --all

Remove all packages in environment /Users/aaronmeurer/anaconda/envs/dot2tex:

$conda create -n dot2tex python=2.7
...
```

Whitespace in error messages
I started creating an environment then cancelled it. The error messages for the later commands have some extra vertical whitespace. Also, the "CondaValueError" part and "Value Error" parts seem like they shouldn't be included in the terminal output.

```
$conda create -n dot2tex python=2.7
CondaValueError: Value error: prefix already exists: /Users/aaronmeurer/anaconda/envs/dot2tex


$conda remove -n dot2tex --all

Remove all packages in environment /Users/aaronmeurer/anaconda/envs/dot2tex:

$conda create -n dot2tex python=2.7
...
```



Discussion:
Another error message issue (should be printed not as an exception):

```
ncurses-5.9-9. 100% |##############################################################################################################| Time: 0:00:10  94.92 kB/s
An unexpected error has occurred.###########################################                                                       | Time: 0:01:14  82.96 kB/s
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues



Current conda install:

               platform : osx-64
          conda version : 4.2.7
       conda is private : False
      conda-env version : 4.2.7
    conda-build version : 2.0.0
         python version : 3.5.2.final.0
       requests version : 2.10.0
       root environment : /Users/aaronmeurer/anaconda  (writable)
    default environment : /Users/aaronmeurer/anaconda
       envs directories : /Users/aaronmeurer/anaconda/envs
          package cache : /Users/aaronmeurer/anaconda/pkgs
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64/
                          https://conda.anaconda.org/conda-forge/noarch/
                          https://repo.continuum.io/pkgs/free/osx-64/
                          https://repo.continuum.io/pkgs/free/noarch/
                          https://repo.continuum.io/pkgs/pro/osx-64/
                          https://repo.continuum.io/pkgs/pro/noarch/
                          https://conda.anaconda.org/asmeurer/osx-64/
                          https://conda.anaconda.org/asmeurer/noarch/
                          https://conda.anaconda.org/r/osx-64/
                          https://conda.anaconda.org/r/noarch/
                          https://conda.anaconda.org/pyne/osx-64/
                          https://conda.anaconda.org/pyne/noarch/
            config file : /Users/aaronmeurer/.condarc
           offline mode : False



`$ /Users/aaronmeurer/anaconda3/bin/conda create -n dot2tex python=2.7`




    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 228, in _error_catcher
        yield
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 310, in read
        data = self._fp.read(amt)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/http/client.py", line 448, in read
        n = self.readinto(b)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/http/client.py", line 488, in readinto
        n = self.fp.readinto(b)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/socket.py", line 575, in readinto
        return self._sock.recv_into(b)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/ssl.py", line 929, in recv_into
        return self.read(nbytes, buffer)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/ssl.py", line 791, in read
        return self._sslobj.read(len, buffer)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/ssl.py", line 575, in read
        v = self._sslobj.read(len, buffer)
    socket.timeout: The read operation timed out

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/models.py", line 664, in generate
        for chunk in self.raw.stream(chunk_size, decode_content=True):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 353, in stream
        data = self.read(amt=amt, decode_content=decode_content)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 320, in read
        flush_decoder = True
      File "/Users/aaronmeurer/anaconda/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 233, in _error_catcher
        raise ReadTimeoutError(self._pool, None, 'Read timed out.')
    requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/fetch.py", line 419, in download
        for chunk in resp.iter_content(2**14):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/models.py", line 671, in generate
        raise ConnectionError(e)
    requests.exceptions.ConnectionError: HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/install.py", line 405, in install
        execute_actions(actions, index, verbose=not context.quiet)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/plan.py", line 643, in execute_actions
        inst.execute_instructions(plan, index, verbose)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/instructions.py", line 134, in execute_instructions
        cmd(state, arg)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/instructions.py", line 47, in FETCH_CMD
        fetch_pkg(state['index'][arg + '.tar.bz2'])
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/fetch.py", line 336, in fetch_pkg
        download(url, path, session=session, md5=info['md5'], urlstxt=True)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/fetch.py", line 438, in download
        raise CondaRuntimeError("Could not open %r for writing (%s)." % (pp, e))
    conda.exceptions.CondaRuntimeError: Runtime error: Could not open '/Users/aaronmeurer/anaconda/pkgs/python-2.7.12-1.tar.bz2.part' for writing (HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.).

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/exceptions.py", line 472, in conda_exception_handler
        return_value = func(*args, **kwargs)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/main.py", line 144, in _main
        exit_code = args.func(args, p)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/main_create.py", line 68, in execute
        install(args, parser, 'create')
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/install.py", line 422, in install
        raise CondaSystemExit('Exiting', e)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/common.py", line 573, in json_progress_bars
        yield
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/install.py", line 420, in install
        raise CondaRuntimeError('RuntimeError: %s' % e)
    conda.exceptions.CondaRuntimeError: Runtime error: RuntimeError: Runtime error: Could not open '/Users/aaronmeurer/anaconda/pkgs/python-2.7.12-1.tar.bz2.part' for writing (HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.).
```

So was this fixed?
I guess you can't ever *fix* "Read timed out."  I've closed over 100 issues today reporting intermittent HTTP errors.  There wasn't one report coming from conda 4.3, where we've dramatically improved the messaging for HTTP errors.  See https://github.com/conda/conda/blob/4.3.17/conda/core/repodata.py#L168-L306 for example.
The bugs here are:

- Too much whitespace in the error messages
- An exception that was printed with a traceback, instead of just the error message

I agree the error itself isn't a bug in conda. 

I'm mostly curious if the extra whitespace was fixed, as I find that quite annoying. 
Another error message issue (should be printed not as an exception):

```
ncurses-5.9-9. 100% |##############################################################################################################| Time: 0:00:10  94.92 kB/s
An unexpected error has occurred.###########################################                                                       | Time: 0:01:14  82.96 kB/s
Please consider posting the following information to the
conda GitHub issue tracker at:

    https://github.com/conda/conda/issues



Current conda install:

               platform : osx-64
          conda version : 4.2.7
       conda is private : False
      conda-env version : 4.2.7
    conda-build version : 2.0.0
         python version : 3.5.2.final.0
       requests version : 2.10.0
       root environment : /Users/aaronmeurer/anaconda  (writable)
    default environment : /Users/aaronmeurer/anaconda
       envs directories : /Users/aaronmeurer/anaconda/envs
          package cache : /Users/aaronmeurer/anaconda/pkgs
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64/
                          https://conda.anaconda.org/conda-forge/noarch/
                          https://repo.continuum.io/pkgs/free/osx-64/
                          https://repo.continuum.io/pkgs/free/noarch/
                          https://repo.continuum.io/pkgs/pro/osx-64/
                          https://repo.continuum.io/pkgs/pro/noarch/
                          https://conda.anaconda.org/asmeurer/osx-64/
                          https://conda.anaconda.org/asmeurer/noarch/
                          https://conda.anaconda.org/r/osx-64/
                          https://conda.anaconda.org/r/noarch/
                          https://conda.anaconda.org/pyne/osx-64/
                          https://conda.anaconda.org/pyne/noarch/
            config file : /Users/aaronmeurer/.condarc
           offline mode : False



`$ /Users/aaronmeurer/anaconda3/bin/conda create -n dot2tex python=2.7`




    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 228, in _error_catcher
        yield
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 310, in read
        data = self._fp.read(amt)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/http/client.py", line 448, in read
        n = self.readinto(b)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/http/client.py", line 488, in readinto
        n = self.fp.readinto(b)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/socket.py", line 575, in readinto
        return self._sock.recv_into(b)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/ssl.py", line 929, in recv_into
        return self.read(nbytes, buffer)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/ssl.py", line 791, in read
        return self._sslobj.read(len, buffer)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/ssl.py", line 575, in read
        v = self._sslobj.read(len, buffer)
    socket.timeout: The read operation timed out

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/models.py", line 664, in generate
        for chunk in self.raw.stream(chunk_size, decode_content=True):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 353, in stream
        data = self.read(amt=amt, decode_content=decode_content)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 320, in read
        flush_decoder = True
      File "/Users/aaronmeurer/anaconda/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 233, in _error_catcher
        raise ReadTimeoutError(self._pool, None, 'Read timed out.')
    requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/fetch.py", line 419, in download
        for chunk in resp.iter_content(2**14):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/requests/models.py", line 671, in generate
        raise ConnectionError(e)
    requests.exceptions.ConnectionError: HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/install.py", line 405, in install
        execute_actions(actions, index, verbose=not context.quiet)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/plan.py", line 643, in execute_actions
        inst.execute_instructions(plan, index, verbose)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/instructions.py", line 134, in execute_instructions
        cmd(state, arg)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/instructions.py", line 47, in FETCH_CMD
        fetch_pkg(state['index'][arg + '.tar.bz2'])
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/fetch.py", line 336, in fetch_pkg
        download(url, path, session=session, md5=info['md5'], urlstxt=True)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/fetch.py", line 438, in download
        raise CondaRuntimeError("Could not open %r for writing (%s)." % (pp, e))
    conda.exceptions.CondaRuntimeError: Runtime error: Could not open '/Users/aaronmeurer/anaconda/pkgs/python-2.7.12-1.tar.bz2.part' for writing (HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.).

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/exceptions.py", line 472, in conda_exception_handler
        return_value = func(*args, **kwargs)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/main.py", line 144, in _main
        exit_code = args.func(args, p)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/main_create.py", line 68, in execute
        install(args, parser, 'create')
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/install.py", line 422, in install
        raise CondaSystemExit('Exiting', e)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/common.py", line 573, in json_progress_bars
        yield
      File "/Users/aaronmeurer/anaconda/lib/python3.5/site-packages/conda/cli/install.py", line 420, in install
        raise CondaRuntimeError('RuntimeError: %s' % e)
    conda.exceptions.CondaRuntimeError: Runtime error: RuntimeError: Runtime error: Could not open '/Users/aaronmeurer/anaconda/pkgs/python-2.7.12-1.tar.bz2.part' for writing (HTTPSConnectionPool(host='binstar-cio-packages-prod.s3.amazonaws.com', port=443): Read timed out.).
```

So was this fixed?
I guess you can't ever *fix* "Read timed out."  I've closed over 100 issues today reporting intermittent HTTP errors.  There wasn't one report coming from conda 4.3, where we've dramatically improved the messaging for HTTP errors.  See https://github.com/conda/conda/blob/4.3.17/conda/core/repodata.py#L168-L306 for example.
The bugs here are:

- Too much whitespace in the error messages
- An exception that was printed with a traceback, instead of just the error message

I agree the error itself isn't a bug in conda. 

I'm mostly curious if the extra whitespace was fixed, as I find that quite annoying. 

Resolving patch:
diff --git a/conda/__init__.py b/conda/__init__.py
--- a/conda/__init__.py
+++ b/conda/__init__.py
@@ -41,7 +41,7 @@ def __init__(self, message, caused_by=None, **kwargs):
         super(CondaError, self).__init__(message)
 
     def __repr__(self):
-        return '%s: %s\n' % (self.__class__.__name__, text_type(self))
+        return '%s: %s' % (self.__class__.__name__, text_type(self))
 
     def __str__(self):
         return text_type(self.message % self._kwargs)
diff --git a/conda/exceptions.py b/conda/exceptions.py
--- a/conda/exceptions.py
+++ b/conda/exceptions.py
@@ -556,7 +556,7 @@ def print_conda_exception(exception):
         stdoutlogger.info(json.dumps(exception.dump_map(), indent=2, sort_keys=True,
                                      cls=EntityEncoder))
     else:
-        stderrlogger.info("\n\n%r", exception)
+        stderrlogger.info("\n%r", exception)
 
 
 def print_unexpected_error_message(e):


Test patch:
diff --git a/tests/test_create.py b/tests/test_create.py
--- a/tests/test_create.py
+++ b/tests/test_create.py
@@ -1104,7 +1104,7 @@ def test_remove_spellcheck(self):
                 run_command(Commands.REMOVE, prefix, 'numpi')
 
             exc_string = '%r' % exc.value
-            assert exc_string == "PackageNotFoundError: No packages named 'numpi' found to remove from environment.\n"
+            assert exc_string == "PackageNotFoundError: No packages named 'numpi' found to remove from environment."
 
             assert_package_is_installed(prefix, 'numpy')