I saw this thread over in the PHP forum, and got thinking since I’ve been guilty of both using a lot of if-else statements for error checking, and just an enclosing try-catch. Where do you draw the line about checking for errors and having too many checks for errors?
A lot can go wrong with opening/reading/writing a file, but most of the code is dedicated to performing that operation, so should you have a chain of if-else statement at the points where things can go wrong, or a catch-all try-catch block?
How do you decide whether a chain of if-else statements is more appropriate than a try-catch? (beyond simple laziness or time constraints)