This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ankostis
Recipients ankostis, brett.cannon, vstinner, yselivanov
Date 2017-03-17.17:15:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489770936.74.0.0159554444939.issue29757@psf.upfronthosting.co.za>
In-reply-to
Content
> When the list of errors is passed as a second argument to the exception, how is it rendered?  

This is how my latest ec887c0c3 looks on Linux:

    >>> import socket
    >>> socket.create_connection(('localhost', 12345))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.5/socket.py", line 714, in create_connection
        raise error("no connection possible due to %d errors" % nerr, errors)
    OSError: [Errno no connection possible due to 2 errors] [ConnectionRefusedError(111, 'Connection refused'), ConnectionRefusedError(111, 'Connection refused')]

And this is on Windows:

    >>> socket.create_connection(('localhost', 12345), 1)
    Traceback (most recent call last):
      File "D:\Apps\WinPython-64bit-3.5.3.0Qt5\python-3.5.3.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "<ipython-input-13-758ac642f3d5>", line 1, in <module>
        socket.create_connection(('localhost', 12345), 1)
      File "D:\Apps\WinPython-64bit-3.5.3.0Qt5\python-3.5.3.amd64\lib\socket.py", line 714, in create_connection
        raise error("no connection possible due to %d errors" % nerr, errors)
    OSError: [Errno no connection possible due to 2 errors] [timeout('timed out',), timeout('timed out',)]

    
> Would it make sense to concatenate all error messages:

But then the user will not receive a list of errors to inspect, but just a big string.
The biggest problem in my latest ec887c0c3 is that I'm abusing the 1st arg to OSError() constructor, instead of being an `errno` it is a string.
But I got that from the existing code.[1]

And still, this PR is not yer finished because there is no feedback on any intermediate errors in the case of success.
As suggested on the OP, this may happen (in my order of preference):

1. with a new argument for the user to provide the list to collect the errors (changes the API backward-compatiblly);
2. with logging logs;
3. with warnings;
4. do nothing.

I prefer logging over warnings because they are more configurable.

[1] https://github.com/python/cpython/blob/master/Lib/socket.py#L724
History
Date User Action Args
2017-03-17 17:15:36ankostissetrecipients: + ankostis, brett.cannon, vstinner, yselivanov
2017-03-17 17:15:36ankostissetmessageid: <1489770936.74.0.0159554444939.issue29757@psf.upfronthosting.co.za>
2017-03-17 17:15:36ankostislinkissue29757 messages
2017-03-17 17:15:36ankostiscreate