Errors
From KnowledgeTree Community
All exceptions and errors in code should be handled with the PEAR::Error class. Using this is straightforward, and can be demonstrated with a quick piece of code.
...
function testme($my_value) {
if (!is_int($my_value)) {
return PEAR::raiseError("Please give me a number to work with");
} else {
return $my_value * 10;
}
}
$new_val = testme("boo");
if (PEAR::isError($new_val)) {
printf ("Couldn't do it, captain: %s", $new_val->getMessage());
} else {
printf("I had the power, captain! Answer is %d", $new_val);
}
del.icio.us
reddit

