Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Previous Exceptions

Since Zend Framework 1.10, Zend_Exception implements the PHP 5.3 support for previous exceptions. Simply put, when in a catch() block, you can throw a new exception that references the original exception, which helps provide additional context when debugging. By providing this support in Zend Framework, your code may now be forwards compatible with PHP 5.3.

Previous exceptions are indicated as the third argument to an exception constructor.

Example 391. Previous exceptions

try {
} catch (
Zend_Db_Statement_Exception $e) {
    if (
$e->getPrevious()) {
'[' get_class($e)
'] has the previous exception of ['
']' PHP_EOL;
    } else {
'[' get_class($e)
'] does not have a previous exception'

// displays all exceptions starting by the first thrown
    // exception if available.

Zend Framework