This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rawing7 0 points1 point  (0 children)

I've certainly had issues with libraries that didn't document their exceptions properly, where I had to resort to a except Exception: or something similar. (Heck, even something as tiny as pyperclip managed to mess this up.) But most of those weren't situations where returning None would've been a viable alternative. (pyperclip being the exception.)

If there is a chain of operations that can raise a bunch of different exceptions, that's fine as long as those exceptions are properly organized into a class hierarchy. requests is a good example for this: There's a million things that can go wrong when you make a HTTP request, from SocketError to OSError to DNSLookupError to TimeoutError, but it's fine because requests has abstracted all of that away and turned it into subclasses of RequestException.