about raiseError()

From: Date: Thu, 30 May 2002 11:23:57 +0000
Subject: about raiseError()
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6655@lists.php.net to get a copy of this message
There is one thing that I don't understand about the raiseError() model that was just added in HTML_Template_IT verses the one used in DB. Personally, I believe the one in DB works better. In DB you create a caller class which extends PEAR_Error, you can set the error message prefix and then determine when the error is raised if it is a DB error, and if so grab the message, if not use a generic error message for DB. So you would have // ClassName would be the name of your class function ClassName_Error($code = CLASSNAME_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null) { if (is_int($code)) { $this->PEAR_Error(ClassName::errorMessage($code), $code, $mode, $level, $debuginfo); } else { $this->PEAR_Error("Invalid error code: $code", CLASSNAME_ERROR, $mode, $level, $debuginfo); } } // Then you call on error return PEAR::raiseError(null, CLASSNAME_SOMEERROR, null, E_USER_WARNING, 'here is your debug info', 'ClassName_Error', true); This way you can set everything, like the severity of the error, the prefix of the error, the debug info of the error...just seems to me like the best way of doing it...only problem is you have to have that caller class for it to work. Dan -- ________________________________________________________________ Daniel Allen, <dan@mojavelinux.com> http://www.mojavelinux.com/ ________________________________________________________________ "This is a test of the Emergency Broadcast System. If this had been an actual emergency, do you really think we'd stick around to tell you?" ________________________________________________________________

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