In case it is obvious, the claim that error handling is
something that you do appropriately to the task is one
that I disagree with. There is virtually no script that
I write that doesn't have error handling somewhere. Whether
5 lines or 5000 I have it in.
That said, I think we all have seen elaborate and stupid
error handling. Error handling - like everythingthing else
in programming - is not an ideal good in and of itself. It
serves a goal. That goal is that if your program does
not do what you want, that it will let you know that with
enough useful information that you can fix the problem.
If you are reporting non-errors, or failing to report
real ones, or failing to be useful - all are bad.
It is important because code is inherently buggy. A claim
that I have heard is that there is an average of one bug
per 10 lines written. Dunno if that is true. (I always
suspect claims with conveniently round numbers in them.)
But certainly the real number is very high. Your error
handling is not where you want those bugs to be.
Therefore you make your scheme very simple, and concentrate
on real errors.
One of which, I guarantee you, is going to be the failure
to open a file you expected to be able to open... |