O 25/09/20 ás 11:52, Chris Angelico escribiu:
But requests.get() doesn't have a single raise statement anywhere in
it. And if you dig through the entire source code for the requests
package, you'll still only find a small number of the exceptions that
might be raised. Errors come from anywhere, and if you're not handling
them, you will simply let them bubble; is it your responsibility to
document that? No. It's just the normal thing to do.

When you want to catch an exception, don't look at the function to see
what it's documented as raising. Look at its behaviour and see what it
does that you can cope with. You're looking at things backwards and
that's why you're wanting a list of possible things to catch. Instead,
look at your program WITHOUT any exception handling, and see what
exceptions are happening. Those are the ones to look at.

ChrisA


Surely there has to be a better way of programming than running stuff, watching it fail, and then keeping track of how it fails so you can later handle that failure?

Don't get me wrong, it's what I've been doing with Python up until now because there's no way around it (other than hoping the library documents how and when common exceptions are raised), but I can't say it I've really *enjoyed* it.

I hope I'm not the only person who sees this as a suboptimal approach? Of course, I could be the weird one out but I frankly doubt it.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W7GVIYVDWK63TYHTYVADR44MFG734MDG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to