The more specific your exception, the more specific you are in what you do to handle that condition. Otherwise you’re always doing one single solitary thing for all error conditions.
You might want to log a specific kind of error, continue on another (in a loop), return from a function on yet another, and if you encounter a really bad error like a socket error you might want to just sys.exit() out of the whole thing since it isn’t going to work anyway.
View all comments
Show parent comment
11
u/[deleted] Jul 14 '21
The more specific your exception, the more specific you are in what you do to handle that condition. Otherwise you’re always doing one single solitary thing for all error conditions.
You might want to log a specific kind of error, continue on another (in a loop), return from a function on yet another, and if you encounter a really bad error like a socket error you might want to just sys.exit() out of the whole thing since it isn’t going to work anyway.