[kdewebdev-webdeveloper] error manager class for PHP4
Eric Laffoon
eric at kdewebdev.org
Fri Oct 29 15:11:26 EDT 2004
Hi all,
I am planning to move my sites to PHP5 but for now I needed to add error
management for PHP4. The reason is that I had sessions dropping data and
realized it was because of spurious errors being printed out before headers
were complete. The idea here is to provide several different types and levels
of error management as well as notification of errors. The matrix is
described in the class. I inform new objects of their name because I have not
found a way to do this in PHP4 so all you need to do is to pass that name.
declare your class
class Connect extends ErrMgr {
var $showRegister = false;
$this->ErrMgr($objname,$showRegister); //initialize error manager
And this is all you need.
Register your errors in derived classes where they will always be read to
avoid creating conflict and to enable reporting.
function registerErrors () {
// errno Dataclass type msg autoexec
$this->registerErr(200,"Dataclass","terminal","If you do not include the
object name in the declaration <b>data operations may behave erratically</b>.
The Kommander script automaticly includes it.",true);
}
Initialize errors when the conditions are met...
$this->setErr(200);
You may add dynamic data to replace the message as an optional second
parameter.
Display error information where you build your page with your class like so...
$this->errTerminal();
$this->errUser();
$this->errDebug();
View your error information reporting per object like so...
$news->errorIndex();
$news->errorDump();
This enables you to track what error numbers have been used and what errors
have been set.
Please feedback if you find this useful. Enjoy!
--
Eric Laffoon
Project Lead - kdewebdev module
-------------- next part --------------
A non-text attachment was scrubbed...
Name: errmgr.php
Type: application/x-php
Size: 5864 bytes
Desc: not available
Url : http://momo.creolmail.org/pipermail/kdewebdev-webdeveloper/attachments/20041029/73f353cf/errmgr.bin
More information about the kdewebdev-webdeveloper
mailing list