-
-
Notifications
You must be signed in to change notification settings - Fork 460
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
requests.exceptions.HTTPError not handled by praw #1825
Comments
Do I have a valid issue here? Should users catch exceptions raised by internal libraries used by praw or should praw catch and raise praw exceptions? |
This probably should be caught by PRAW. But this feature drills down directly to the underlying network package (requests) and bypasses the error handler in place in prawcore. Yes, either PRAW or prawcore should catch this like you suggest. |
Yes, this exception should be caught. It's one of the few rare places where PRAW is directly making a request and we don't have special exception handling around it. @endlisnis would you like to try to add this exception handling in? |
Sure. I can give it a shot. I have a patch ready. Is there some sort of test suite I can run on my change? |
Yes. Should be able to do just |
OK. I have a pull request ready. It passed pytest, and I fixed the lint problem; although I don't understand the rules for where to put imports; but I just used the suggestion. |
I'm having a hard time getting a unit test to work. My first attempt was to just literally duplicate the "test_submit_image2" test, but even a literal duplicate of that test fails. I'm perplexed. I suspect it has something to do with Here's my test:
And here's the failure output:
|
You'll want to do something similar to this test: praw/tests/unit/models/reddit/test_subreddit.py Lines 58 to 71 in b009cbf
|
Thanks for the pointer. I was able to get something working, but I have to say that writing the test was about 100 times harder than writing the actual code. |
This issue is stale because it has been open for 20 days with no activity. Remove the Stale label or comment or this will be closed in 10 days. |
I'm still working on this. Just having some trouble getting the testing code working. Thanks for the reminder, bot. |
Sounds good! Would you like some help? If so, feel free to open a PR and I can take a look. |
Just checking in on if this is still something you're working on. |
To be honest, I gave up on this. I got distracted by life stuff. I'm going on paternity leave starting in June for several months. It's possible that I might get a chance to look at it then, but I wouldn't count on it. Feel free to give this to someone else if you want. |
No worries! I'm on parental leave too so my time is limited as well. I'll take care of this for ya! |
Describe the Bug
When I was using
submit_image
, praw encountered a 500 internal server error.I have a handler for
praw.exceptions.RedditAPIException
, but that did not get caught because arequests.exceptions.HTTPError
was raised instead of apraw.exceptions.RedditAPIException
.I assume that the intent is to have praw except exceptions from "requests" and raise them as praw exceptions (to avoid clients depending on knowledge of internal design).
Desired Result
praw should have raised a
praw.exceptions.RedditAPIException
(or one of the classes that inherit from that)Relevant Logs
Code to reproduce the bug
# I don't have a reproduction because in requires reddit to send back a 500.
My code example does not include the
Reddit()
initialization to prevent credential leakage.Yes
This code has previously worked as intended.
No
Operating System/Environment
Linux Mint 20.2 Cinnamon
Python Version
Python 3.8.10
PRAW Version
7.5.0
Prawcore Version
2.3.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: