|
Posted by Benjamin Esham on 09/03/06 02:52
lawrence k wrote:
> [should I write my own error checking?]
I believe other posters have given pretty firm answers to that... let me
just make a suggestion in the name of readability.
Instead of writing
if ( ! $thereIsAnError ) {
...
if ( ! $thereIsAnotherError ) {
...
} else {
// handle the second problem
} else {
// handle the first problem
}
use
if ($thereIsAnError)
handle_error($thereIsAnError);
...
As you can see, this puts the error checking first in the file, and it also
prevents the unholy levels of if/else nesting that can occur if you use
if/else blocks for all of your error checking. Assuming that handle_error()
will exit, you can just add a quick, two-line test to check for and handle
an error; there's no need to wrap the entire rest of the code in an else { }
block.
HTH,
--
Benjamin D. Esham
bdesham@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
'I wish I had never come here, and I don't want to see no more
magic,' he said and fell silent.
— Sam in /The Fellowship of the Ring/
Navigation:
[Reply to this message]
|