Error Handling

From: Date: Tue, 24 Apr 2001 12:56:56 +0000
Subject: Error Handling
Groups: php.general 
Request: Send a blank email to php-general+get-50058@lists.php.net to get a copy of this message
Is there a good write up out there or can anyone offer some insight to the rest of us as to how error handling should be properly implemented? Yes, PEAR has some error handling routines, but it doesn't have any kind of information as to how it should be "properly" implemented. I've just finished writing a pretty decent error handling class of my own but going through my code, I see places where I can add the trigger_error() function, but beyond that, I'm not sure exactly how to process it all. Up to now, I've just been doing some generic error handling. If a query fails, if a user enters the wrong value, I print out a message. But now that I'm handling all the errors, I'm finding that I'm getting so many more messages from PHP than I was before. For example, if a variable wasn't "properly" initialized (ie, I'll get an error in this case: $mode = "add"; if( $mode == "add" ) { $joe = "bob"; } if( $joe ) { echo "You got here"; } an error will be thrown by PHP saying that $joe is uninitialized) It's not as if that's a big deal. It isn't. But since I'm getting more information than I need to actually give the end user, it seems like kind of a daunting task to start handling the errors myself. It is something we are going to need to do so I cannot put it off. But I am hoping that there is some sort of write up or tutorial or something out there where I can learn from the experience of others as to how something like this should be done "properly". I'd rather do something of this magnitude right the first time. As an aside, in writing this class and seeing how PHP works in this regard, I've so much more respect for what PHP actually does behind the scenes with regards to error and syntax checking. It was definitely a learning experience. Chris

« previous php.general (#50058) next »