
Originally Posted by
fukas78
I recommend to you look inside the PEAR project.
There is great example how to handle errors via classes.
http://pear.php.net
It looks like methods in the pear library return a "PEAR_Error" object.
If I understand the code correctly it doesn't look like you can
check the boolean return value of a method as usual because it
might return an object?
That means you can't do something like the following
because it might return an object:
PHP Code:
if ($obj->doSomething() )
{ echo 'I love doing something!<br>';
}
Is this a good thing? I like knowing that my functions will either return
true or false or something else, but not both. Am I right in thinking this?
I was thinking that maybe I could make an "error" member object in each class
that needs it.
Then maybe you could do something like this:
PHP Code:
if ($obj->doSomething() )
{ echo 'I love doing something!<br>';
}
else
{ $errorObj = $obj->getErrorObj();
}
Does that look reasonable?
Of course I'm also gonna have to get used to the whole try/catch way of doing
things too I guess.. ERghh..
--ed
Bookmarks