Making PEAR_ErrorStack throw PHP5 exceptions

From: Date: Fri, 19 Nov 2004 23:51:10 +0000
Subject: Making PEAR_ErrorStack throw PHP5 exceptions
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15711@lists.php.net to get a copy of this message
Hi all, I've been using the DB API. Now that I'm moving to PHP5, I'd like to get it throwing exceptions instead of returning error objects. While the documentation suggests that this should work, I'm having trouble getting PEAR_ErrorStack to do this. http://pear.php.net/manual/en/core.pear.pear-errorstack.intro.php suggests this: <?php require_once 'PEAR/ErrorStack.php'; $stack = &PEAR_ErrorStack::singleton('mypackage', false, null, 'PEAR_ErrorStack', false, 'MyException'); ?> But (after changing MyException to say 'PEAR_Error') this doesn't seem to do anything - it runs, but errors are still returned in the usual way, no exception is thrown. Similarly "PEAR_ErrorStack::singleton('DB', false, false, false, 'PEAR_Error')", which is what I think the 'singleton' method documentation says I should be using, has no effect. Is there something else I need to do to set it up to throw exceptions, or is the documented syntax not correct? FWIW "PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION, 0);" works fine - exceptions are thrown from then on - except that it produces the deprecation warning... Cheers, Will _______________________________________________________________________
Will Bryant, will@core-dev.co.nz                    cell +64 21 655 443
http://www.core-dev.co.nz/             Personal: http://carcino.gen.nz/


« previous php.pear.general (#15711) next »