Yes you are right, if I am aware of what can be wrong I use to insert some "checkpoints" in the code to check if a table exists, if a table is empty, etc.
But there are some cases (like this one) in which if you use external sources, external databases, external files (excel, etc), there are so many things that may go wrong that it would be very very very verbose to predict all possibilities (connection failed, schema does not exists, table does not exists, column does not exists, column type is wrong, a table is not well indexed on a databases so the query has a timeout, an excel has a wrong number of columns, an excel sheet name is wrong, etc etc sooo many).
So in these case I prefer to just run the code and check at the end if something went wrong: if so, I notify the users responsible of the sources and I proceed to the next iteration. If they want their output, they must fix their sources and then the procedure can run again, that's perfectly fine! I don't care and I move on to the next iteration which is completely independent of the results of the previous one.
Thank you again
Regards
... View more