Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (37 sloc) 1.85 KB
- Covert namespace to PEAR2
- Removed getCause() as it just uses the built in getPrevious() that was added in PHP 5.3
- Removed getUniqueId as it's used anywhere
- Removed toHtml, toText and __toString (which only handled calling the former two).
People should implement their owny decorator calls.
- Removed the built in outputs of the observer functions. Those where the class constants
OBSERVER_PRINT, OBSERVER_TRIGGER, OBSERVER_DIE
This can be achieved by writing a custom callback function, using the appropriate printf(),
trigger_error and die() to achieve the same result.
- Removed getErroClass and getErrorMethod as it can be easily gotten from getTrace/getTraceSafe first array element
- Add the proper LICENSE file and move Exception.php to the NEW BSD license as the package.xml already defines
- Removed __toString, toText and toHtml. For those wanting to get pretty outputs they can use this approach:
$causes = array();
$this->getCauseMessage($causes);
foreach ($causes as $i => $cause) {
var_dump($cause);
}
And combine that with getTraceSafe() or getTraceAsString() if needed.
Put all that in a function and use set_exception_handler('exceptionHandler'); or similar to process
all Exceptions.
Example code or see the removed code at http://svn.php.net/viewvc/pear2/Exception/trunk/src/Exception.php?r1=295348&r2=295352 :
function exceptionHandler($e)
{
if ($e instanceof \PEAR2\Exception) {
$causes = array();
$e->getCauseMessage($causes);
$causeMsg = '';
foreach ($causes as $i => $cause) {
$causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': '
. $cause['message'] . "\n";
}
echo $causeMsg;
} else {
echo $e->getMessage(), "\n";
}
}
set_exception_handler('exceptionHandler');
Jump to Line
Something went wrong with that request. Please try again.