Catch error class

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Catch error class

Post by fastfingertips »

I would like to make an error class to catch all the errors and drop them into a log file or table, so i would like to know if you can make me a recommendation to find best way to resolve this poblem. :?:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Is there something further you want to do than can be achieved with php.ini settings?

This will log everything to file.

error_reporting=E_ALL
log_errors=On

This toggles the sending of error messages as part of the output to the client:

display_errors=Off/On
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

Short answer: PEAR, and its packages

phpOO Classes already exist to catch errors, log them any which way, and even implement an Observer paradigm to watch the logs and keep you informed. No sense reinventing the wheel.

peace
jaxn
Forum Commoner
Posts: 55
Joined: Fri Jan 16, 2004 1:50 pm
Location: Nashville, TN

Post by jaxn »

This is one of the features of CEP (http://sourceforge.net/projects/cep).

We make use of the PEAR Error objects and maintain a global error array and at the end of the script execution all errors that are supposed to be logged are written to the logfile.

That is an oversimplification of how we do it (it is really cascading error objects), but it works really well.

The API that we use for our error handling is one command too so it is easy to have all the error checking you should have without losing readability.

-Jackson
Post Reply