On Fri, Sep 25, 2020 at 7:59 PM Sergio Fenoll <ser...@fenoll.be> wrote: > > 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?
Why? Do you really think you can enumerate EVERY possible way that something might fail? Think, instead, about all the possible problems that you can actually cope with. That way, you have a finite - and usually small - set of things to deal with, instead of an infinite field of "well this could go wrong, but we can't do anything about that". In the list of all possible failures, will you include MemoryError? What would you do if one got raised? If the answer is "nothing, just let it propagate", then it doesn't need to be in the list. Same goes for every other exception ever invented. ChrisA _______________________________________________ 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/TZ5AOOEBFMD7HTP6A2JFLP25HFUBRT2Q/ Code of Conduct: http://python.org/psf/codeofconduct/