You can use the normal try/catch/throw blocks that you would normally use in any other PHP app. Refer to the PHP manual on that:
PHP: Exceptions - Manual
You can just do something like this:
PHP Code:
try {
// the code I'm trying to run
} catch (Exception $e) {
// do something with the error
echo $e->getMessage();
// Consider using Zend_Log to log the error
}
The framework has extended the PHP Exceptions, with Zend_Exception, which is explained briefly here:
Zend Framework: Manual: Zend_Exception
So you can use Zend_Exception instead of Exception in the above code. Also be aware that some of the components extend Zend_Exception and may have another Exception object you can use too. Depends on the circumstances.
You can also throw your own errors in ZF. Using the missing id for the db record example, you can just do something like this:
PHP Code:
if(!isset($id)) {
$e = new Exception;
throw $e;
}
You'll still need to catch the error you throw, but this should get you started.