As previously noted exception linking was recently added (and what a god-send it is, it certainly makes layer abstraction (and, by association, exception tracking) easier).
Since <5.3 was lacking this useful feature I took some initiative and creating a custom exception class that all of my exceptions inherit from:
<?php
class SystemException extends Exception
{
private $previous;
public function __construct($message, $code = 0, Exception $previous = null)
{
parent::__construct($message, $code);
if (!is_null($previous))
{
$this -> previous = $previous;
}
}
public function getPrevious()
{
return $this -> previous;
}
}
?>
Hope you find it useful.