Page 1 of 1

Error checking - When is too much.

Posted: Tue Jan 21, 2003 3:51 pm
by EricS
This is more a question about theory than an actual coding problem. I've been taking error checking very serious of late and am getting better and better at. But it seems that you could error check just anything you do and my code is starting to look more like one big error check than an application. I don't mind writing the code, it's strain that all this overhead is adding the server that I'm worried about.

For instance. I'm writing a template class that receives a filename, checks that there is in fact a filename passed, checks that the file exists, reads the file, checks that it has in fact read something in and is not just empty, implodes it to string and sets the string to a class property. Then when you want to modify the template, it checks that you have a template already set, checks to see if you've actually given any changes, and then makes the changes. Then when you want to display, it checks to see if you have a template set, then displays the template, and tells the calling script that it's succeeded or failed.

Is this going overboard. Should we be striving to have PHP applications that never show those nasty default PHP errors, and instead show nicely formatted error that were prewritten by guess who....ME.

What do you think? Smart Programmer or Eagerly Over Zealous.

Posted: Tue Jan 21, 2003 4:53 pm
by JPlush76
I think it depends on what type of site you're coding for. For example I just finished an ecommerce site that passes data to an AS400 for processing. I had to do error checking out the ass to make sure good data was getting passed.

If I was doing a little personal homepage I dont think it would matter nearly as much. It can't hurt to be too careful.

Posted: Tue Jan 21, 2003 9:02 pm
by fractalvibes
I think you are on the right track with the error checking. To some extent I have to interface Web stuff with an OS/390 behomoth and ancient systems, and whole-heartly agree with Jim. I think you will always find yourself writing a bulk of code to handle the odd situation, the exceptions.
A pain, no doubt, but in the long run will save you much grief.

Phil J.