Re: PEAR.php to PHP5
| From: | Hans Lellelid | Date: | Sat, 19 Jun 2004 17:22:55 +0000 |
| Subject: | Re: PEAR.php to PHP5 | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30937@lists.php.net to get a copy of this message | ||
Hi Tomas,
Cool. I've added some stuff: 1) Still like to have some pre-made observers useful for quick debug. Allthought simplified their addition. 2) Added more debuggin info avaible 3) Implemented $exception->toString() (will output HTML if REQUEST_URI is detected). It looks like: PEAR_Exception occurred: Error message: Failed first Error code : 2 File (Line) : /home/cox/www/php5/exceptions-1.php (125)I like that. I would add a non-static getCause() method (which I just forgot) and perhaps replace getNestedMethod() with something slightly more comprehensive (showing file/line) maybe "getCauseMessage" "getNestedMessage" "buildCauseMessage". ...but in general, that's the idea I had too, yeah. Notes: - you don't need to specify or explicitly set the $message, $file, $line, $code; AFAIK these are protected properties of Exception; the $file and $line will be correctly set from the original throw and not from parent::__construct(). - what about overriding __toString() instead of adding a new toString()? Besides avoiding any confusion, I believe __toString() is the one non-final method of the Exception class, so it can be overrided to produce the nice looking output you implemented. Plus then you can just: } catch(PEAR_Exception $e) { print $e; } to get full debug info. Also, this means that any non-PEAR calling code that is only expecting Exception will be able to take advantage of that same nicely formatted output. i.e. } catch(Exception $e) { print $e; } (no need to catch on PEAR_Exception and use toString()) Cool, yo. HansMethod : test::first()Nested Error : test::first()<-test::second()<-test::third()