-
Notifications
You must be signed in to change notification settings - Fork 119
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
Add handling for exceptions raised by requests library #123
Add handling for exceptions raised by requests library #123
Conversation
Can one of the admins verify this patch? |
ok to test |
I feel like this could perhaps do more. Do you think it would be possible for the exception to contain more details about the request that failed? Perhaps the endpoint that it tried to request? Other than that, this looks fine. |
Done. Let me know if you'd like even more info than that included. Given that the circumstances where requests would raise an exception for one matrix endpoint but not another are relatively rare, I think this should be sufficient along with the traceback for debugging. |
matrix_client/api.py
Outdated
) | ||
except requests.exceptions.RequestException as e: | ||
raise MatrixHttpLibError( | ||
"Something went wrong in {} requesting {}".format(method, endpoint), e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal preference is to pass in method and endpoint as parameters to the exception and format it inside the constructor, in case I might want to disassemble it as a handler down the line.
Other than that, LGTM 👍 |
can we merge this? using this sdk, without able to catch exceptions by requests library, is really annoying :< |
We should also add the request-timeout to this pull request (see #157) |
@4nd3r apologies if absence of this is affecting things for you. I'll prioritize this one. As it stands right now, you could directly catch exceptions raised by |
Signed-off-by: Adam Beckmeyer <[email protected]>
Signed-off-by: Adam Beckmeyer <[email protected]>
8081c31
to
10db977
Compare
Use of requests is an implementation detail, so we shouldn't let exceptions raised by requests leak through to any application developers.
Technically this may need a major version bump since someone may have been manually handling exceptions raised by requests. But I doubt it.