Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop squashing OsError into ConnectionRefusedError when connecting #21

Conversation

lenzenmi
Copy link
Contributor

I've seen the light, you are absolutely correct. I didn't see your comment earlier, it was hidden as I had already modified that section of code.

This should bring things back in order, should have done it earlier, sorry for the extra work.

Yes, it depends. For that use case of simply retrying a connection for any type of failure, I agree that it's more convenient to catch one exception than two. However some clients may want to behave differently depending on the type of error.

For example, if the server actively refuses a connection it may be because Rabbit isn't running; whereas if the socket can't be opened it more likely indicates a local failure. By shoving both errors into one exception, we're ruling out the possibility of clients distinguishing the two types of failure; plus it's hard to go back to two exceptions because of backwards compatibility.

The from e trick does partially address this loss of information, but it's more designed for debugging than error handling.

If a client really does want to retry on all failures, you can just catch any type of exception (except Exception as e).

@benjamin-hodgson
Copy link
Owner

Thanks for the contribution 😄

benjamin-hodgson pushed a commit that referenced this pull request May 25, 2015
Stop squashing OsError into ConnectionRefusedError when connecting
@benjamin-hodgson benjamin-hodgson merged commit 30e7cf0 into benjamin-hodgson:master May 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants