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.

Title: OSError: multiple exceptions should preserve the exception type if it is common
Type: Stage:
Components: asyncio Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: aymeric.augustin, christian.heimes, gvanrossum, iritkatriel, nanjekyejoannah, r.david.murray, terry.reedy, yselivanov
Priority: normal Keywords:

Created on 2017-04-04 17:12 by r.david.murray, last changed 2022-04-11 14:58 by admin.

Messages (5)
msg291126 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-04-04 17:12
create_connection will try multiple times to connect if there are multiple addresses returned by getaddrinfo.  If all connections file it inspects the exceptions, and raises the first one if they are all equal.  But since the addresses are often different (else why would we try multiple times?), the messages will usually be different.  When the messages are different, the code raises an OSError with a list of the exceptions so the user can see them all.  This, however, looses the information as to *what* kind of exception occurred (ie: ConnectioRefusedError, etc).

I propose that if all of the exceptions raised are of the same subclass, that that subclass be raised with the multi-message list, rather than the base OSError.
msg291127 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-04-04 17:13
If all connections fail (not file :)
msg291288 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-04-07 19:47
I agree.  And if the sub-exceptions are different, prepend them to the messages in the OSError list.
msg340147 - (view) Author: Aymeric Augustin (aymeric.augustin) * Date: 2019-04-13 08:44
A very similar issue came up here:

When raising an exception that gathers multiple sub-exceptions, it would be nice to be able to iterate the exception to access the sub-exceptions.
msg381869 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-11-25 23:31
The feature request reminds me of Nathaniel and Yury have been discussing the idea of a MultiError handler for a while.
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74166
2021-05-22 17:19:34iritkatriellinkissue29757 superseder
2020-11-25 23:31:25christian.heimessetnosy: + christian.heimes
messages: + msg381869
2020-11-25 22:20:33iritkatrielsetnosy: + iritkatriel
2020-11-25 20:30:03gvanrossumsetnosy: + gvanrossum
2019-04-18 22:51:16nanjekyejoannahsetnosy: + nanjekyejoannah
2019-04-13 08:44:08aymeric.augustinsetnosy: + aymeric.augustin
messages: + msg340147
2017-04-07 19:47:43terry.reedysetnosy: + terry.reedy
messages: + msg291288
2017-04-04 17:13:24r.david.murraysetmessages: + msg291127
2017-04-04 17:12:21r.david.murraycreate