Re: Re: PEAR_Exception in CVS

From: Date: Fri, 02 Jul 2004 09:49:16 +0000
Subject: Re: Re: PEAR_Exception in CVS
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-31485@lists.php.net to get a copy of this message
Missing from it: a) printf() type messages for arguments: (needed to enable translatable messages) Possible solution:? throw new PEAR_Exception("mymessage", MY_ID) throw new PEAR_Exception(array("my message %s",$somearg), MY_ID)
Umm, this would need to accept that params and accept something a callback for actually doing the translation no? Why not pass directly the translated string?
I guess since translation is not something you really want to mess around with when writing and maintaining the class/packages. The idea of being able to add a translation hook in the error handler would allow those who wanted to use translated messages, a simple mechanism to do it. eg. PEAR_Exception::translator(array(&$translator,'get')); PEAR_Exception::translator('gettext'); or better, just make the translator a special observer.. (although it does more than observe!) - keeps the API kiss.. and thin. PEAR_Exception::addObserver('translator','gettext'); PEAR_Exception::addObserver('translator',array(&$translator,'get'));
- A static method for pushing errors in the internal stack - A static method for getting the array of warnings - Ability to attach observers to warnings too.
PEAR_Exception::addObserver('warning',PEAR_OBSERVER_TRIGGER);
$foo = new foo; $foo->bar(); $warnings = PEAR_Exception::getWarnings($class = null);
$warning = PEAR_Exception::lastWarning(); or just $warning = PEAR_Exception::last(); maybe only store the last warning/exception?.. - if you want to know more, then adding PEAR_Exception_Stack as an observer to PEAR_Exception would be more effecient - that way we avoid storing a huge array of historical data unnecessarily. Regards Alan -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.pear.dev (#31485) next »