Re: [Fwd: Re: [PEAR-DEV] Re: [ANNOUNCEMENT] HTML_CSS-1.0.0RC1 (beta)Released.]

From: Date: Fri, 29 Jul 2005 16:02:11 +0000
Subject: Re: [Fwd: Re: [PEAR-DEV] Re: [ANNOUNCEMENT] HTML_CSS-1.0.0RC1 (beta)Released.]
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-39025@lists.php.net to get a copy of this message
Hi Lukas, Lukas Smith wrote:
Lukas Smith wrote:
[1] http://cvs.php.net/pear/HTML_CSS/docs/errorHandlerGuide.txt [2] http://cvs.php.net/co.php/pear/HTML_CSS/CSS.php?r=1.43#1386 [3] http://cvs.php.net/co.php/pear/HTML_CSS/CSS.php?r=1.43#1437 [4] http://cvs.php.net/co.php/pear/HTML_CSS/CSS.php?r=1.43#1468 [5] http://cvs.php.net/co.php/pear/HTML_CSS/CSS/Error.php?r=1.2
So essentially your approach is to keep the implementation of raiseError() inside a user defineable callback? That seems straight forward enough to me. I was fearing there would be alot more code involved. I didnt dig much deeper, but I wonder: are there any public methods that get called from the class itself. In that case I wonder how you deal with the fact that people could set some random error handler? Actually I looked a bit deeper and it seems very few internal method calls have any sort of error handling. So I am really not sure if you are getting this external error handling flexibility by essentially eliminating all internal error handling.
Perharps you did't see examples especially those who present the error handling system and almost all details of customization. here there are (also included into latest bundle 1.0.0RC1): [1] change display render : http://cvs.php.net/co.php/pear/HTML_CSS/examples/css_error_custom.php?r=1.2 [2] ignore all errors raised : http://cvs.php.net/co.php/pear/HTML_CSS/examples/css_error_ignore.php?r=1.2 [3] errors are logged into a database : http://cvs.php.net/co.php/pear/HTML_CSS/examples/css_error_logger.php?r=1.2 [4] example of PEAR_ErrorStack implementation : http://cvs.php.net/co.php/pear/HTML_CSS/examples/css_errorstack_custom.php?r=1.2 To resume: 1. This error handling system, never include 'PEAR.php' (as many pear packages did), but only if there is at least one error. 2. The configuration options (callback of generation : context and message, and more ...) are set with the last parameter of class constructor => initialized by function http://cvs.php.net/co.php/pear/HTML_CSS/CSS.php?r=1.43#1386 And that's all. The CSS/Error.php will manage all render (log, display) for a PEAR_Error usage. Example [4] will do almost the same but for PEAR_ErrorStack usage. And you can plugin your own error handler by following example pattern [4]. I did it myself in past: a class that never raise either a PEAR_Error or a PEAR_ErrorStack. So if we count only HTML_Common, the HTML_CSS could be used without PEAR itself. Even if it's not the goal, it's possible.
Furthermore it would be a good idea to offer a static isError() method so that people can check for HTML_CSS specific errors if they want.
As default behaviour raise a PEAR_Error, you may test with require_once 'HTML/CSS.php'; $css = new HTML_CSS(); $result = $css->setStyle('div', 'color', 5); if (PEAR::isError($result)) { // do something when an error is raised } But, perharps we could also add, what i did for HTML_Progress2, see: raiseError(), hasErrors(), and getError() http://cvs.php.net/co.php/pear/HTML_Progress2/Progress2.php?r=1.5#3524 an error stack to keep all errors raised, even with PEAR_Error (part of idea, yeah of PEAR ErrorStack )
regards, Lukas
Hope i've answered to all your questions ! regards Laurent

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