Home » PEAR » PEAR » Bug #5322
Clean up docs and handling of exceptions
Details
| Submitted | 2005-09-07 14:40 UTC |
|---|---|
| From | sd at sven-drieling dot de |
| Status | Duplicate |
| Package | PEAR |
| PHP Version | 5.0.4 |
| Roadmaps | (Not assigned) |
Comments
[2005-09-07 14:40 UTC] sd at sven-drieling dot de
Description:
------------
Clean up docs and handling of exceptions with PEAR.
The PEAR manual does not describe that PEAR_ERROR_EXCEPTION is
deprecated.
"PEAR_ERROR_EXCEPTION If Zend Engine 2 is present, then an
exception will be thrown using the PEAR_Error object."
PEAR::setErrorHandling('PEAR_ERROR_EXCEPTION') produces later warnings
that PEAR_ERROR_EXCEPTION is obsolete and you should use PEAR_ErrorStack.
if ($this->mode & PEAR_ERROR_EXCEPTION) {
trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class
PEAR_ErrorStack for exceptions", E_USER_WARNING);
But since version PEAR1.3.2, ErrorStack no longer instantiates an exception class.
Bug #3990 PEAR_Error PEAR_EXCEPTION broken
http://pear.php.net/bugs/bug.php?id=3990
Makes the suggestion to generate PEAR_Exception().
<?php
function PEAR_ErrorToPEAR_Exception($err)
{
if ($err->getCode) {
throw new PEAR_Exception($err->getMessage(),
$err->getCode();
}
throw new PEAR_Exception($err->getMessage());
}
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK,
'PEAR_ErrorToPEAR_Exception');
?>
But the PEAR_Exception() API is in alpha state.
// $Id: Exception.php,v 1.5 2005/03/28 16:38:58 cellog Exp $
/**
* Base PEAR_Exception Class
*
* WARNING: This code should be considered stable, but the API is
* subject to immediate and drastic change, so API stability is
* at best alpha