{"action":"created","issue":{"url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/466","labels_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/466/labels{/name}","comments_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/466/comments","events_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/466/events","html_url":"https://github.com/KeepSafe/aiohttp/issues/466","id":100399476,"number":466,"title":"Exception handling changes exception types unexpectedly","user":{"login":"bitdancer","id":476443,"avatar_url":"https://avatars.githubusercontent.com/u/476443?v=3","gravatar_id":"","url":"https://api.github.com/users/bitdancer","html_url":"https://github.com/bitdancer","followers_url":"https://api.github.com/users/bitdancer/followers","following_url":"https://api.github.com/users/bitdancer/following{/other_user}","gists_url":"https://api.github.com/users/bitdancer/gists{/gist_id}","starred_url":"https://api.github.com/users/bitdancer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitdancer/subscriptions","organizations_url":"https://api.github.com/users/bitdancer/orgs","repos_url":"https://api.github.com/users/bitdancer/repos","events_url":"https://api.github.com/users/bitdancer/events{/privacy}","received_events_url":"https://api.github.com/users/bitdancer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-11T20:18:47Z","updated_at":"2015-08-11T20:36:14Z","closed_at":null,"body":"I was surprised that my 'except OSError' did not catch network related errors from my application's 'request' call.  The root error was ConnectionResetError, which is a subclass of OSError, and so I would have expected that catching OSError would catch it.  But it gets turned into a ServerDisconnectedError, which is not a subclass of OSError.  Now, it would be simple enough and logical enough to make DisconnectedError a subclass of OSError.  However, the ServerDisconnectedError in turn gets turned into a ClientResponseError (using raise from) for reasons I don't understand, so even if DisconnectedError were an OSError the OSError would still be masked.  In fact I note that the clauses in that same area of client.py explicity turn OSErrors into ClientOSErrors, which I see has been fixed to be a subclass of OSError, but something that started out as an OSError has gotten converted to something else.  Based on looking at that part of the code, I suspect there may be similar problems with masking HTTPErrors.\r\n\r\n(I'm not clear on why there are so many custom exception classes, but I wasn't part of the development so I won't comment further on that :)"},"comment":{"url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/comments/130059407","html_url":"https://github.com/KeepSafe/aiohttp/issues/466#issuecomment-130059407","issue_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/466","id":130059407,"user":{"login":"bitdancer","id":476443,"avatar_url":"https://avatars.githubusercontent.com/u/476443?v=3","gravatar_id":"","url":"https://api.github.com/users/bitdancer","html_url":"https://github.com/bitdancer","followers_url":"https://api.github.com/users/bitdancer/followers","following_url":"https://api.github.com/users/bitdancer/following{/other_user}","gists_url":"https://api.github.com/users/bitdancer/gists{/gist_id}","starred_url":"https://api.github.com/users/bitdancer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitdancer/subscriptions","organizations_url":"https://api.github.com/users/bitdancer/orgs","repos_url":"https://api.github.com/users/bitdancer/repos","events_url":"https://api.github.com/users/bitdancer/events{/privacy}","received_events_url":"https://api.github.com/users/bitdancer/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T20:36:14Z","updated_at":"2015-08-11T20:36:14Z","body":"This may be another issue, but...I just printed out the error message from the ClientResponseError I got, and it is...absolutely nothing.  Not exactly useful.  I guess I'll have to log the entire exception chain in order to find out what went wrong, which is something I'd rather not do in production, since I don't want to log exceptions when the problem is just a network timeout.\r\n\r\nI think it would be much more useful to just let the exceptions bubble up.  At the very least the error message needs to include the error message of the exception being masked.\r\n\r\nTo put it another way, the value of exception hierarchies is to allow the application to decide to respond to more specific exceptions, or to instead respond to a boad group of exceptions.  Because aiohttp catches the specific exceptions and masks them under a generic exception, the application is prevented from deciding to take action specific exceptions.  My application would have to chase the exception chain in order to find out what *really* when wrong when I get a ClientResponseError, yet I can't on the other hand decide to handle all network related errors by catching OSError because ClientResponseError is not part of a logical exception hierarchy."}}