Re: Re: Making PEAR_ErrorStack throw PHP5 exceptions
| From: | Jeroen Houben | Date: | Mon, 22 Nov 2004 11:20:35 +0000 |
| Subject: | Re: Re: Making PEAR_ErrorStack throw PHP5 exceptions | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15754@lists.php.net to get a copy of this message | ||
Hi Greg,
Greg Beaver wrote:
Of course, you can customize the DBException to include the original PEAR_Error object if you would like. However, far simpler for your purposes is to simply use a PEAR_Error callback <?php require_once 'PEAR.php'; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchPEAR'); class DBException extends Exception {} function catchPEAR($err) {Cheers, Jeroenthrow new DBException($err->getMessage(), $err->getCode();} ?> Will this turn all PEAR errors into Exceptions? What if I just wanted to repackage PEAR::DB errors? Can I safely do DB::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchPEAR'); ??